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/bash | |
wget https://credis.googlecode.com/files/credis-0.2.3.tar.gz | |
tar -zxvf credis-0.2.3.tar.gz | |
cd credis-0.2.3 | |
make |
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
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited | |
# | |
# Current known FCC address ranges: | |
# https://news.ycombinator.com/item?id=7716915 | |
# | |
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft | |
# | |
# In your nginx.conf: | |
location / { |
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
curl -d 'auth_token=....' \ | |
-d 'device_tokens[]=...' \ | |
-d 'title=Test' \ | |
-d 'body=Hello' \ | |
-d 'label=View' \ | |
-d 'url_args[]=message_id' \ | |
-d 'url_args[]=12345' \ | |
https://api.zeropush.com/notify |
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
require 'digest' | |
require 'json' | |
REQUIRED_ICONSET_FILES = ["icon_16x16.png", "icon_16x16@2x.png", "icon_32x32.png", "icon_32x32@2x.png", "icon_128x128.png", "icon_128x128@2x.png" ] | |
manifest_keys = REQUIRED_ICONSET_FILES.map{|f| 'icon.iconset/' + f } | |
manifest_keys << 'website.json' | |
manifest_values = manifest_keys.map {|file| Digest::SHA1.file(file).hexdigest } | |
manifest_data = Hash[manifest_keys.zip(manifest_values)].to_json |
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
#don't send the nginx version number in error pages and Server header | |
server_tokens off; | |
# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security | |
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping | |
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; | |
# config to don't allow the browser to render the page inside an frame or iframe | |
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking | |
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri |
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
require 'socket' | |
server = TCPServer.open(2195) | |
connection = server.accept | |
loop { | |
data = connection.read(8) | |
puts "Received \"#{data}\"" | |
if data == "CCCCCCCC" | |
connection.write("error") | |
connection.close |
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
require 'open3' | |
require 'fileutils' | |
if ARGV[0].nil? | |
puts "This script requires a directory to operate on" | |
exit 1 | |
end | |
def file_names(path) | |
Dir.glob("#{path}/**/*").map do |file| |
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
KEEP_EXTS = [".mp3",".jpg",".mid",".MP3",".wma",".m4a",".JPG",".mpg",".JPEG",".m4v",".mp4",".mov",".flac"] | |
UNWANTED_EXTS = [".ini",".db",".txt",".md5",".nfo",".pls",".info",".sfv",".NFO",".SFV",".url",".bal",".ogg",".php",".m3u",".LOG",".sls",".log",".pdf"] | |
CONVERT_EXTS = [".wma"] | |
def files(path) | |
Dir.glob("#{path}/**/*") | |
end | |
def find_files(path) |
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
require 'restclient' | |
require 'json' | |
require 'digest' | |
class IGDownloader | |
def initialize(output_path) | |
@base_output_path = output_path | |
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
#include <stdio.h> | |
/* https://twitter.com/mikeash/status/240471662422810624 | |
* Compute average with no possibility of integer overflow. | |
* Note: patented in 1996, so you can't use it! | |
*/ | |
int patentedAverage(int a, int b) | |
{ | |
int av = (a/2) + (b/2) + (a&b&1); | |
return av; |