Skip to content

Instantly share code, notes, and snippets.

View barce's full-sized avatar

Barce barce

View GitHub Profile
@barce
barce / export.rake
Created October 29, 2013 18:14
code for creating a seeds.rb file from user objects
namespace :export do
desc "Prints seeds in a seeds.rb format"
task :seeds_format => :environment do
User.order(:id).all.each do |user|
# doesn't work on dreamhost
puts "User.create(#{user.serializable_hash.delete_if { |key, value| ['created_at','updated_at','id'].include?(key)}.to_s.gsub(/[{}]/,'')})"
end
end
end
@barce
barce / placeholder.js
Created October 4, 2013 18:54
If you need to use the placeholder attribute in IE8, this javascript will make it work.
//
// This is placeholder functionality for IE.
//
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
## Ensure to load the imfile module to monitor a >nginx< log file
## Add in main rsyslog.conf
$ModLoad imfile
## Explicitly state file monitor interval - unsupported in old version - cheggit
# $InputFilePollingInterval 10
## The file that you'd watch and log
$InputFileName /var/log/access_log
## Something to help you label the log entry - useful for filters
@barce
barce / rsyslog_master.conf
Created June 27, 2013 20:42
rsyslog.conf master
# /etc/rsyslog.conf Configuration file for rsyslog.
#
# For more information see
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf
#################
#### MODULES ####
@barce
barce / gist:4497663
Created January 9, 2013 22:38
quicksort in haskell
qsort [] = []
qsort (p:xs) = (qsort lesser) ++ [p] ++ (qsort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs
@barce
barce / unicode_punct.rb
Created November 13, 2012 02:00
converts japanese punctuation into unicode hex codes
#!/usr/bin/env ruby
# encoding: utf-8
#
#、-〿⦅-・
s = Array.new
s << '、'
s << '〿'
s << '⦅'
s << '・'
@barce
barce / pg_startup.tsch
Created November 7, 2012 18:55
startup postgresql on mac os x
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/.
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
@barce
barce / upload.php
Created October 30, 2012 21:21
Sample Upload for Via.Me API in PHP
<?php
$api_url = 'http://api.via.me/v1/post';
$access_token = 'YOUR_ACCESS_TOKEN_HERE';
$img_url = '/Users/newuser/foo/bar.jpg';
$msg = 'test';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
@barce
barce / ckjv.bash
Created June 22, 2012 00:41
grepping for Hiragana, Katana and Romanji
#!/bin/bash
grep '[\x{4E00}-\x{9FBF}|\x{3040}-\x{309F}|\x{30A0}-\x{30FF}]' test.txt
@barce
barce / SSL on Node.js
Created June 8, 2012 16:58
how to get node.js served over ssl
diff --git a/upload.js b/upload.js
index 6bd2d90..6b32b17 100644
--- a/upload.js
+++ b/upload.js
@@ -20,7 +20,17 @@ airbrake = require('airbrake').createClient('b8aa2614cff629cff9e3a0bde1d061bc'),
// require('v8-profiler'); // only needed for dev
// create your express server
-var app = module.exports = express.createServer();
+var hskey = fs.readFileSync('hacksparrow-key.pem');