Skip to content

Instantly share code, notes, and snippets.

View rococodogs's full-sized avatar

Anna Malantonio rococodogs

View GitHub Profile
@rococodogs
rococodogs / qs2obj.js
Created July 24, 2014 19:31
generate object from querystring via src (stolen from http://feather.elektrum.org/book/src.html)
// get qs from src path
// http://feather.elektrum.org/book/src.html
var scripts = document.getElementsByTagName('script');
var thisIdx = scripts.length - 1;
var thisScript = scripts[thisIdx];
var qs = {};
var str = thisScript.src
.replace(/^[^\?]+\??/, '') // strip out address
.split(/\&/) // split on ampersands
.map(function(it){ // parse thru each key=val, split on equal sign and assign to qs object
@rococodogs
rococodogs / delete_date_interval.sql
Last active August 29, 2015 14:04
HistoricalCats db cleanup
delete from tweets where timestamp < (NOW() - INTERVAL 6 MONTH)
@rococodogs
rococodogs / parseDateString.js
Created August 7, 2014 23:40
put a lot of effort into this and ended up not using it. can't get myself to just delete it, even though I can't remember if it even works.
function parseDateString(str, options) {
var options = options || {}
, american = options.american_format
, local = options.local_time
, reg = {}
, sampleDate = new Date()
, y = 0, mo = 0, d = 0, h = 0, mi = 0, s = 0
, days = [
'mon',
@rococodogs
rococodogs / composer.json
Created September 4, 2014 18:28
cron'd php script to scrape our Ricoh printer's page counts to keep a running tally on our end
{
"require": {
"sunra/php-simple-html-dom-parser": "1.5"
}
}
@rococodogs
rococodogs / sedin.md
Last active August 29, 2015 14:06
replace instances of "user" with "quest-user" from the command line

i'm so proud that i decided to make a gist of it

grep -Frl "'user'" views | xargs sed -i .delete-me "s/\'user\'/\'quest-user\'/g"

@rococodogs
rococodogs / snake_to_camel_case.php
Created September 13, 2014 14:03
underlines to camelcase
<?php
function underline_to_camel_case($str) {
return lcfirst(implode("", array_map(function($e) {
return ucfirst($e);
}, explode("_", $str))
)
);
}

Keybase proof

I hereby claim:

  • I am malantonio on github.
  • I am malantonio (https://keybase.io/malantonio) on keybase.
  • I have a public key whose fingerprint is 0AE5 A6B1 45C5 0021 C667 E883 D35D F190 6A83 E53E

To claim this, I am signing this object:

@rococodogs
rococodogs / cellar_door_bot_app.rb
Last active August 29, 2015 14:13
one of these days i'll learn to use ruby in an oop manner
require "yaml"
require "twitter"
require "net/http"
require "json"
config = YAML.load_file("config.yml");
client = Twitter::REST::Client.new do |c|
c.consumer_key = config['consumer_key']
c.consumer_secret = config['consumer_secret']
c.access_token = config['access_token']
@rococodogs
rococodogs / proc_usage.php
Created February 15, 2015 17:44
spelling out how to use php's proc
<?php
$process = proc_open(
'wc', // cmd to run
// define yr pipes
[
['file', __FILE__, 'r'], // stdin (passing file to wc)
['file', 'output.txt' , 'w'] // stdout (output, we could also echo stream_get_contents of $pipes[1])
],
// var to store the above
$pipes
@rococodogs
rococodogs / newjob.cli.js
Created February 17, 2015 00:53
sometimes you just need to see what's out there
#!/usr/bin/env iojs
var path = require('path')
, fs = require('fs')
, jsonPath = path.join(__dirname, 'places.json')
, jobs = require(jsonPath)
, places = jobs.places
, spawn = require('child_process').spawn
, argv = require('minimist')(process.argv.slice(2))
, prompt = require('prompt')