Skip to content

Instantly share code, notes, and snippets.

View eristoddle's full-sized avatar

Stephan Miller eristoddle

View GitHub Profile
#!/bin/bash
# nodereinstall
# credit: http://stackoverflow.com/a/11178106/2083544
#
# UPDATE: I've converted this gist to a repo:
# https://github.com/brock/node-reinstall
#
# get sudo
@eristoddle
eristoddle / revert.sh
Last active August 29, 2015 14:21 — forked from kugaevsky/revert.sh
$ cd /usr/local
$ git checkout b64d9b9c431642a7dd8d85c8de5a530f2c79d924 Library/Formula/node.rb
$ brew unlink node
$ brew install node
$ npm install -g npm@latest
#include <unistd.h>
#include <node.h>
#include <string.h>
#include <v8.h>
using namespace v8;
unsigned long long count = 0;
// native blocking/compute intensive function
@eristoddle
eristoddle / file_parser.py
Created June 7, 2012 15:19
Parse files with mod date in folders and output html
"""
I use this for files I save in Epistle for Android when I save links from my6sense. Yes, a very specific use case, but it might be useful to others.
"""
import os, time, webbrowser, glob
l = [(os.stat(i).st_mtime, i) for i in glob.glob('*txt')]
l.sort()
files = [i[1] for i in l]
files.reverse()
<?php
use lithium\core\Libraries;
use lithium\net\http\Router;
use lithium\core\Environment;
/* define lithium library path */
define('LITHIUM_LIBRARY_PATH', dirname(__DIR__) . '/lithium/libraries');
if (!include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php') {
$message = "Lithium core could not be found. Check the value of LITHIUM_LIBRARY_PATH in ";
$message .= __FILE__ . ". It should point to the directory containing your ";
@eristoddle
eristoddle / htaccess_hack_finder.py
Created June 28, 2012 15:33
Find .htaccess hacks in your website with Python
import os
#Replace with name of directory to scan, i.e, your WP directory
dir = "/var/www/"
#Replace with string to find, in my case, this domain, which my site was redirecting to
to_find = "vlag-nerto.ru"
for root, dirs, files in os.walk(dir):
for file in files:
fullpath = os.path.join(root, file)
@eristoddle
eristoddle / piwikSiteLog.php
Created July 11, 2012 16:16
Simple script to correlate Piwik visits with a website changes log
<?php
//The url to your Piwik folder
$p_url = "";
//The id of your site in Piwik
$site_id = "";
//Your Piwik token_auth
$token_auth = "";
function write_log($message) {
$log_file = 'logfile.txt';
@eristoddle
eristoddle / headers.php
Created August 13, 2012 03:00
JSON API headers for PHP
<?php
//JSON headers
header('Cache-Control: no-cache, must-revalidate');
header('Expires: '.gmdate('D, d M Y H:i:s', time()).' GMT');
header('Content-type: application/json; charset=utf-8');
?>
@eristoddle
eristoddle / yt1.jquery.js
Created September 19, 2012 17:22
Very specific YouTube Jquery example
(function($){
$.fn.youtube = function(options){
return this.each(function(i, obj){
var $this = $(obj),
$playBtns = $this.find('.video .play-btn'),
player,
onPlayerReady = function(){
player.playVideo();
},
loadPlayer = function(id){
@eristoddle
eristoddle / jobserver.py
Created September 19, 2012 17:30
Very Tiny Python Job Server
#!/usr/bin/python
from lib import scheduler
import datetime, time
def eristoddle_post_server(every_min, run_time_min):
from core.myWP import zem_cb_eristoddle
every_sec = 60 * every_min
run_time = 60 * run_time_min
esched = scheduler.Scheduler()
etask = scheduler.Task("eristoddle_post",