Skip to content

Instantly share code, notes, and snippets.

@kuntalchandra
kuntalchandra / ImageResizerMultiProcess.php
Created September 14, 2017 13:34
Forking multiple processes in PHP using pcntl_fork()
<?php
include("Lib.php");
class ImageResizerMultiProcess
{
private $sizes = [];
public function setSizes($sizes)
{
(function () {
var e = {}, t = {}, n = 0,
r = {
refreshStylesheets: function () {
function i(e) {
var t = document.location,
n = new RegExp("^\\.|^/(?!/)|^[\\w]((?!://).)*$|" + t.protocol + "//" + t.host);
return e.match(n)
}
var n = document.getElementsByTagName("head")[0],
@thomaswitt
thomaswitt / list_all_google_apps_users.rb
Created November 14, 2013 14:54
Access Google Apps Admin SDK Directory API and retrieve all users from Google Apps
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'google/api_client'
require 'active_support/core_ext/hash'
# 1. Go to Google Cloud Console (https://cloud.google.com/console)
# 2. Create Service Account with P12 File
# 3. Enable the Admin SDK in APIs.
@jpstroop
jpstroop / c4l_loris_lightning_talk.md
Last active December 12, 2015 12:19
Lightning talk re: Loris <https://github.com/pulibrary/loris> for code4lib 2013.
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active April 17, 2024 12:35
Using Git with Subversion Mirroring for WordPress Plugin Development
@plexus
plexus / root_certificates.rb
Created May 11, 2012 13:29
Monkey patch Ruby 1.9 net/http to read system's root certificates
# Please fork if you can improve this. (e.g. Windows support)
#
# Ruby 1.9 doesn't contain any SSL root certificates, neither does it read the ones
# installed with your operating system. This results in an error like
#
# SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
#
# This solution is based on http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/
# but can be used to monkey patch 3rd party tools, e.g. Github's 'gist' command.
#
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@mayoff
mayoff / gist:1138816
Last active December 8, 2023 22:00
AppleScript to make Google Chrome open/reload a URL
(* To the extent possible under law, Rob Mayoff has waived all copyright and related or neighboring rights to “AppleScript to make Google Chrome open/reload a URL”. This work is published from: United States. https://creativecommons.org/publicdomain/zero/1.0/ *)
tell application "Google Chrome"
activate
set theUrl to "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
if (count every window) = 0 then
make new window
end if
set found to false
@chrisbloom7
chrisbloom7 / longest_common_substring.php
Created June 12, 2011 03:27
Find the longest common substring in an array of strings (PHP)
<?php
function longest_common_substring($words)
{
$words = array_map('strtolower', array_map('trim', $words));
$sort_by_strlen = create_function('$a, $b', 'if (strlen($a) == strlen($b)) { return strcmp($a, $b); } return (strlen($a) < strlen($b)) ? -1 : 1;');
usort($words, $sort_by_strlen);
// We have to assume that each string has something in common with the first
// string (post sort), we just need to figure out what the longest common
// string is. If any string DOES NOT have something in common with the first
// string, return false.