Skip to content

Instantly share code, notes, and snippets.

@pkrnjevic
pkrnjevic / patch-glib-2.0.pc.in.diff
Created December 19, 2011 07:22
corrected homebrew patch file for glib package
--- glib-2.0.pc.in.orig 2011-08-03 16:45:19.000000000 -0500
+++ glib-2.0.pc.in 2011-08-17 01:59:10.000000000 -0500
@@ -12,4 +12,4 @@
Version: @VERSION@
Libs: -L${libdir} -lglib-2.0 @INTLLIBS@
-Libs.private: @ICONV_LIBS@
+Libs.private: @ICONV_LIBS@ @GLIB_RT_LIBS@
-Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include @GLIB_EXTRA_CFLAGS@
+Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I${includedir} @GLIB_EXTRA_CFLAGS@
@pkrnjevic
pkrnjevic / mariadb.db
Created March 15, 2012 02:22
Slightly changed mariadb.rb brew recipe to cook mariadb 5.3.5 instead for 5.2.x
require 'formula'
class Mariadb < Formula
# You probably don't want to have this and MySQL's formula linked at the same time
# Just saying.
#url 'http://ftp.osuosl.org/pub/mariadb/mariadb-5.2.8/kvm-tarbake-jaunty-x86/mariadb-5.2.8.tar.gz'
url 'http://nfl/mariadb-5.3.5.tar.gz'
homepage 'http://mariadb.org/'
md5 '98ce0441b37c8d681855150495fdc03b'
@pkrnjevic
pkrnjevic / Gemfile
Created March 15, 2012 02:28
Sample Gemfile supporting ruby 1.9.3-p125 and mysql2 working with mariadb-5.3.5
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'pg'
gem 'mysql2'
@pkrnjevic
pkrnjevic / http.rb.snippet
Created March 18, 2012 16:31
One line fix for ruby 1.9.3 net/http to find ca-bundle.crt
# Turn on/off SSL.
# This flag must be set before starting session.
# If you change use_ssl value after session started,
# a Net::HTTP object raises IOError.
def use_ssl=(flag)
flag = flag ? true : false
if started? and @use_ssl != flag
raise IOError, "use_ssl value changed, but session already started"
end
@pkrnjevic
pkrnjevic / intersect.pl
Created April 13, 2012 05:02
Simple script to find strings common to all files specified on command line. (the intersection)
#!/usr/bin/env perl
# Read each file specified on command line and print lines found in all files
#
open(FH,$ARGV[0]); chomp(@isect = <FH>); close(FH);
shift(@ARGV);
while (@ARGV) {
## read each file into an array and strip newlines
open(FH,$ARGV[0]); chomp(@f = <FH>); close(FH);
@pkrnjevic
pkrnjevic / intersect.rb
Created April 13, 2012 05:04
Similar to intersect.pl but in ruby. This version just reads files "file1 file2 file3".
#!/usr/bin/env ruby
require 'digest/sha1'
# Build an array of hashes for each file, using sha1 of line as key
def get_digests_for_file(file_name)
h = {}
File.readlines(file_name).each do |line|
h[Digest::SHA1::digest line] = line
end
h
. $topsrcdir/browser/config/mozconfig
export MOZ_APP_NAME=securebrowser
export MOZ_APP_DISPLAYNAME=SecureBrowser
mk_add_options MOZ_APP_NAME=securebrowser
mk_add_options MOZ_APP_DISPLAYNAME=SecureBrowser
ac_add_options --enable-application=browser
mk_add_options MOZ_OBJDIR=c:/mozilla-objs-msvc
@pkrnjevic
pkrnjevic / Google AppEngine log
Created January 16, 2013 19:09
Google AppEngine error when attempting to download pdf from http://www.dynalinktech.com/downloads/manual.pdf
2013-01-16 10:29:12.450 /downloads/manual.pdf 500 38ms 0kb Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.29 Safari/537.22
74.14.183.104 - - [16/Jan/2013:10:29:12 -0800] "GET /downloads/manual.pdf HTTP/1.1" 500 0 "http://www.dynalinktech.com/html/index.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.29 Safari/537.22" "www.dynalinktech.com" ms=39 cpu_ms=21 instance=00c61b117c56c7e2a91c0735235775634465988b
E 2013-01-16 10:29:12.446
'utf8' codec can't decode byte 0xe2 in position 10: invalid continuation byte
Traceback (most recent call last):
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/python27_runtime/python27_lib/ve
@pkrnjevic
pkrnjevic / gist:4956784
Created February 14, 2013 22:00
Slightly modified fsnotify-test.go. In theory this would add newly created directories to the active watcher. In practise, on OS X, it quickly runs out of file resources and crashes.
package main
import (
"github.com/howeyc/fsnotify"
"log"
"os"
)
func ExampleNewWatcher() {
watcher, err := fsnotify.NewWatcher()
@pkrnjevic
pkrnjevic / gist:5125165
Created March 9, 2013 18:31
Snippet using libepeg (in Go).
C.epeg_decode_size_set(im.cim, C.int(width), C.int(height))
C.epeg_quality_set(im.cim, C.int(quality))
var scaledData *C.uchar
var scaledSize C.int
C.epeg_memory_output_set(im.cim, &scaledData, &scaledSize)
C.epeg_encode(im.cim)