Skip to content

Instantly share code, notes, and snippets.

View song940's full-sized avatar
👨‍💻
Typing ...

Lsong song940

👨‍💻
Typing ...
View GitHub Profile
@song940
song940 / relay.py
Created February 8, 2014 01:32
Raspberry Pi and Relay
import RPi.GPIO as GPIO
import web
PIN = 7
# to use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)
# set up GPIO output channel
GPIO.setup(PIN, GPIO.OUT)
urls = (
#!/usr/bin/python
import sys
from twisted.web import http, proxy
from twisted.internet import reactor
HEAD = 'Fuck GFW\x01\r\n'
f = http.HTTPFactory()
f.protocol = proxy.Proxy
if 'client' in sys.argv:
_connectTCP = reactor.connectTCP # redirect to our server
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>Float Label Pattern</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style type="text/css" media="screen">
.row {
/*position: relative;*/
padding-top: 24px;
@song940
song940 / happycast.rb
Created March 11, 2014 03:28
HappyCast.net Episodes Downloader .
#encoding = utf-8
require "nokogiri"
require "open-uri"
def fetch_page(i)
page_url = "http://happycasts.net/episodes/#{i}"
begin
doc = Nokogiri::HTML(open(page_url))
link = doc.css('a.download').first
require 'sinatra' # gem install sinatra --no-rdoc --no-ri
set :port, 3000
set :environment, :production
html = <<-EOT
<html><head><style>
#text{width:100%; font-size: 15px; padding: 5px; display: block;}
</style></head><body>
<input id="text" placeholder="Write then press Enter."/>
<div id="chat"></div>
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
import sys
import bencode
import hashlib
import base64
import urllib
torrent_file = sys.argv[1]
torrent = open(torrent_file, 'r').read()
metadata = bencode.bdecode(torrent)
import commands
def get_cpu_temp():
tempFile = open( "/sys/class/thermal/thermal_zone0/temp" )
cpu_temp = tempFile.read()
tempFile.close()
return float(cpu_temp)/1000
# Uncomment the next line if you want the temp in Fahrenheit
#return float(1.8*cpu_temp)+32
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
#!/bin/bash
/etc/init.d/ntp stop
until ping -nq -c3 8.8.8.8 > /dev/null; do
echo "Waiting for network..."
done
ntpdate -s time.nist.gov