Skip to content

Instantly share code, notes, and snippets.

@mgraupner
mgraupner / gist:1859298
Last active September 30, 2015 20:47
MacOS X 10.7.3 and XCode 4.3: Installing Ruby, Gem and Rails
Made an update covering Macos 10.8 and ruby 2.0: https://gist.github.com/michaelsd/5224456
- Install "Command Line Tools for XCode" (Get it from Apple Developer Program) or Install XCode via Appstore
where option one is the faster one, 170MB vs 1.xGB
- Install https://github.com/sstephenson/rbenv
git clone into your home folder;
set environment variables, see install docs of rbenv;
- Get libyaml
@nvk
nvk / readme
Created April 19, 2012 18:20
Using Git with Dropbox
### Instructions source http://tumblr.intranation.com/post/766290743/using-dropbox-git-repository ####
-- make empty repo on dropbox:
cd ~/Dropbox/RipeApps/Git
mkdir -p newname.git
cd !$
git --bare init
-- push your junk into it
cd ~/Projects/myrepo
@Florian95
Florian95 / simple_search.rb
Created April 24, 2012 11:34 — forked from jimworm/simple_search.rb
Simple search for all Rails 3.2 ActiveRecord models on any string column(s)
class ActiveRecord::Base
class << self
def has_simple_search(*attrs)
raise 'has_simple_search expects at least one attribute' if attrs.empty?
instance_eval do # because this is ActiveRecord::Base, the class inherits this
class_attribute :simple_search_fields
self.simple_search_fields = attrs.flatten
def simple_search(search_string)
return find(:all) if search_string.nil? || search_string.blank?
attrs = self.simple_search_fields
@FichteFoll
FichteFoll / prettify_markdown_table.py
Created May 12, 2012 02:09
Plugin for Sublime Text 2 that "prettifies" MultiMarkdown tables and aligns their vertical separators
from sublime import Region
import sublime_plugin
"""
This plugin for Sublime Text 2 searches for tables with a style like:
| I'm a header | I'm second|lolol|
|:-|-:|::|
| I'm a cell | yeah, you bet ||
@jboner
jboner / latency.txt
Last active June 17, 2024 02:27
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@ttscoff
ttscoff / editscript.rb
Created July 7, 2012 01:26
Fuzzy CLI file search through configured directories, ranked results displayed as menu
#!/usr/bin/env ruby
# encoding: utf-8
# == Synopsis
# Proof of concept using Fuzzy File Finder to locate a script to edit
# Searches a set of predefined locations for a fuzzy string
# e.g. "mwp" matches both "myweatherprogram" and "mowthelawnplease"
# ................on "(m)y(w)eather(p)rogram" and "(m)o(w)thelawn(p)lease"
#
# Results are ranked and a menu is displayed with the most likely
# match at the top. Editor to be launched and directories to search
@wendlers
wendlers / smartplug.py
Last active October 16, 2023 21:41
Simple library/command-line-utility to control a EDIMAX Smart Plug Switch (SP-1101W) from Python
##
# The MIT License (MIT)
#
# Copyright (c) 2014 Stefan Wendler
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -B6 bindings:.*:
@pixeltrix
pixeltrix / time_vs_datatime.md
Last active February 18, 2024 19:20
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@cdzombak
cdzombak / Drop Action.scpt
Created June 3, 2015 03:13
OmniFocus AppleScript to move an action to my "❌ Dropped" context and mark it completed.
property droppedContext : "Dropped"
tell application "OmniFocus"
tell front document
try
set theDroppedContextID to id of item 1 of (complete droppedContext as context)
set theDroppedContext to first flattened context whose id is theDroppedContextID
on error
display alert "No context found whose name contains “" & droppedContext & "”"
return