This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aggregateTimes(...timeStrings) { | |
const timeUnits = { h: 3600, m: 60, s: 1 }; | |
let totalSeconds = 0; | |
for (const timeString of timeStrings) { | |
if (typeof timeString === 'string' || timeString instanceof String) { | |
const matches = timeString.match(/(\d+)([hms])/g); | |
if (matches) { | |
for (const match of matches) { | |
const [, value, unit] = match.match(/(\d+)([hms])/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
void ptimestamp_micro(struct timespec *now, char *text) | |
{ | |
long us = (now->tv_sec * 1000000) + (now->tv_nsec / 1000); | |
printf("%ld%s", us, text); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <getopt.h> | |
#include <time.h> | |
#define VERSION_H \ | |
"#ifndef %s_VERSION_H\n" \ | |
"#define %s_VERSION_H\n" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
usage() { | |
cat << EOF | |
usage: req [--version] [--help] <command> [<args>] | |
The most commonly used req commands are: | |
add Add requirement contents to the index | |
new Create a requirement | |
init Create an empty req repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Runtime.InteropServices; | |
namespace HelloApp | |
{ | |
class HelloLibrary | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Runtime.InteropServices; | |
namespace HelloApp | |
{ | |
class HelloLibrary | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: clean uninstall | |
prefix ?= /usr | |
exec_prefix ?= $(prefix) | |
bindir ?= $(exec_prefix)/bin | |
ETHERWAKE_src = ether-wake.c | |
ETHERWAKE_bin = ether-wake | |
ETHERWAKE_tgt = $(DESTDIR)$(bindir)/etherwake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#define PRINT_INTERVAL 1000 /* in milliseconds */ | |
#define MILLI 0 | |
#define MICRO 1 | |
#define NANO 2 | |
#define RESOLUTION MILLI | |
long diff_nano(struct timespec *start, struct timespec *end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=UTF-8 | |
import sys, subprocess | |
p = subprocess.Popen(["acpitool", "-ab"], stdout=subprocess.PIPE) | |
output = p.communicate()[0] | |
# find the line with the battery percentage | |
o_cur = [l for l in output.splitlines() if '%' in l][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/ioctl.h> | |
#include "termios_dbg.h" | |
#define CHECK_BIT(var, pos) ((var) & (1<<(pos))) | |
void ptermios_iflag(struct termios *tty) | |
{ | |
printf("c_iflag=0x%x\n", tty->c_iflag); |
NewerOlder