Skip to content

Instantly share code, notes, and snippets.

View seabre's full-sized avatar

Sean Brewer seabre

  • CrowdFiber
  • Chattanooga, TN
View GitHub Profile
@seabre
seabre / export_table_as_csv_from_mysql.md
Created April 4, 2012 18:55
Export Table as CSV From MySQL

#Export Table as CSV From MySQL

SELECT * INTO OUTFILE '/tmp/my_table_name.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM my_table_name;

@seabre
seabre / blumblumshub.coffee
Created April 15, 2012 03:52
Blum Blum Shub Pseudo Random Number Generator
# An implementation of assert.
AssertException = (message) ->
@message = message
assert = (exp, message) ->
throw new AssertException(message) unless exp
AssertException::toString = ->
"AssertException: " + @message
@seabre
seabre / sitemap_all_urls.py
Created April 27, 2012 16:51
Get All URLs From Sitemap
import xml.dom.minidom
dom = xml.dom.minidom.parse("sitemap.xml")
loc = dom.getElementsByTagName('loc')
for node in loc:
print node.firstChild.data
@seabre
seabre / devise_login_rails_console.rb
Created June 1, 2012 20:51
Devise Login Through Rails Console
ApplicationController.allow_forgery_protection = false
app.post('/whatever_my_user_model_is/sign_in', {"whatever_my_user_model_is"=>{"email"=>"users@email.com", "password"=>"users_password"}})
@seabre
seabre / import_csv_rails_activerecord.rb
Created June 1, 2012 20:59
Import CSV Into Rails Application via ActiveRecord
# If you are using a gem like paper_trail that records
# user edit history, you should "login" first.
# See this gist for more details if you are
# using Devise:
# https://gist.github.com/2855072
require 'csv'
csv_text = File.read('my_csv_file_to_import.csv')
@seabre
seabre / pagespeed.js
Created October 11, 2012 18:44
Pagespeed crawler for PhantomJS
var address, sitemap, system;
sitemap = require('webpage').create();
system = require('system');
if (system.args.length === 1) {
console.log('Usage: pagespeed.js <some DOMAIN>');
phantom.exit(1);
} else {
@seabre
seabre / Gemfile
Created December 18, 2012 04:03
Simple example to find possible tag/topic of a text.
source "http://rubygems.org"
gem 'uea-stemmer'
gem 'stopwords'

Pairing With tmux

Host

$ tmux -S /tmp/pair
$ chmod 777 /tmp/pair

Client

@seabre
seabre / emailaddrgtandeq.py
Last active December 11, 2015 02:39
Get e-mail address in between < and >
value.strip().match(/<(.*?)>/)[0]
ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) *2^(8-i));if(k)printf("%0o ",k);print}'