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/make -sf | |
$(if $(i),,$(error Usage: twitter-stats i=twitter-YYYY-MM-DD-sha256.zip [lang|users|1.png|1.svg])) | |
n=5 | |
top: tweets.json | |
json -e 'this.tweet.permalink = `https://twitter.com/i/web/status/$${this.tweet.id}`; this.tweet.rating = Number(this.tweet.favorite_count) + Number(this.tweet.retweet_count)' -c 'this.tweet.rating > 0' < $< | json -Ae 'this.sort((a,b)=> a.tweet.rating-b.tweet.rating)' | json -Ae 'this.q = this.slice(-$(n))' q | json -e 'this.q = {rating: this.tweet.rating, date: this.tweet.created_at, text: this.tweet.full_text, permalink: this.tweet.permalink}' -a q | |
lang: tweets.json; json -a tweet.lang < $< | $(aggregate) | $(sort) |
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 | |
errno=0 | |
sys=/sys/class/net | |
# $1 == nic | |
dump() { | |
[ -d "$sys/$1" ] || { echo "$1 is absent" 1>&2; errno=2; return; } | |
echo Name "$1" | pp |
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/make -f | |
# Requires nokogiri & gnuplot | |
# | |
# curl http://feeds.5by5.tv/b2w | ./podcast-dow 1.png [title=hello] | |
plot = @nokogiri -e 'puts $$_.css("item pubdate").map{|n| Date.parse(n).strftime("%Y-%m-%d %u %a")}' | cat <(echo "$$script") - | gnuplot -e 'set term $1;' - > $@ | |
%.png:; $(call plot,png) | |
%.svg:; $(call plot,svg) |
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 | |
# -*-coding:utf-8-unix-*- | |
usage() { echo Usage: ipconfig \| `basename $0` [-v] [-m NUM] pattern 1>&2; exit 2; } | |
while getopts "vm:" o; do | |
case $o in | |
v) opt_v=! ;; | |
m) opt_m=$OPTARG ;; | |
*) usage |
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
let Transform = require('stream').Transform | |
let FeedParser = require('feedparser') | |
let pump = require('pump') | |
class Filter extends Transform { | |
constructor(articles_max, feedparser) { | |
super() | |
this._writableState.objectMode = true // we can eat objects | |
this.articles_max = articles_max | |
this.articles_count = 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
/* | |
An extract of patsubst function from GNU Make 4.2.90 | |
(6f339b22eb87dc80d1037ccb04c787d156db0e8f) | |
$ cc gmake-patsubst.c -o gmake-patsubst | |
$ ./gmake-patsubst %.c %.o 'foo.c bar.c' | |
foo.o bar.o | |
*/ | |
#include <stdio.h> |
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
<# | |
.SYNOPSIS | |
Read stdin & feed it to the system TTS engine. | |
#> | |
param( | |
# Sets the speaking rate in real time. | |
[int] [ValidateRange(-10, 10)] $r = 0, | |
# Specify a voice (use -l to get the valid names). | |
[string] $voice = "", | |
# Print available voices. |
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 ruby | |
# -*-ruby-*- | |
require 'pp' | |
require 'minitest/autorun' | |
class Pocket | |
MAX = 16 | |
attr_reader :stones, :name | |
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 ruby | |
# -*-ruby-*- | |
require 'erb' | |
class UnityFixture | |
def initialize | |
@tests = {} | |
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
# -*-ruby-*- | |
require 'benchmark' | |
STEP = 500 | |
ROUNDS = 8 | |
FILES = 'rec-files' | |
FILES_N = (1..ROUNDS).inject(0) {|i,j| i + j*STEP } | |
#FILES_LEN = Math.log(FILES_N, 10).floor + 1 # works only in 1.9 | |
FILES_LEN = FILES_N.to_s.size |
NewerOlder