Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
jakebellacera / ICS.php
Last active July 10, 2024 11:27
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@mikelikespie
mikelikespie / refresh_css.js
Created October 27, 2010 18:31
This refreshes all the css on a page by changing the query string
/*
Add a bookmark to this
javascript:(function(){var c=document.getElementsByTagName("link");for(var d=0;d<c.length;d++){var a=c[d];if(a.rel=='stylesheet'||a.type=="text/css"){var e="css_buster_"+Math.floor(Math.random()*1000000000);var g=a.href.split("?",2);var f;if(g.length>1){var b=g[1].indexOf("&")==-1;if(b){f=e}else{f=g[1]+"&"+e}}else{f=e}a.href=g[0]+"?"+f}}})();
*/
(function() {
var links = document.getElementsByTagName('link');
for (var i = 0; i < links.length; i++) {
var l = links[i];
if (l.rel == 'stylesheet' || l.type == 'text/css') {
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@marxian
marxian / auto_transform_geometries.js
Created August 1, 2011 15:32
GeoJSON + OSM + OpenLayers
var geojson_format = new OpenLayers.Format.GeoJSON({
'internalProjection': new OpenLayers.Projection("EPSG:900913"),
'externalProjection': new OpenLayers.Projection("EPSG:4326")
});
@wadey
wadey / iterm2.zsh
Last active July 10, 2024 06:20
Change iTerm2 tab color when using SSH
# Usage:
# source iterm2.zsh
# iTerm2 tab color commands
# https://iterm2.com/documentation-escape-codes.html
if [[ -n "$ITERM_SESSION_ID" ]]; then
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
@3demax
3demax / tabbar-tweak.el
Created October 5, 2011 14:58
Emacs tabbar-mode visual tweaks
;; This are setting for nice tabbar items
;; to have an idea of what it looks like http://imgur.com/b0SNN
;; inspired by Amit Patel screenshot http://www.emacswiki.org/pics/static/NyanModeWithCustomBackground.png
;; Tabbar
(require 'tabbar)
;; Tabbar settings
(set-face-attribute
'tabbar-default nil
:background "gray20"
@sendos
sendos / Show images inline
Created January 6, 2012 23:09
Bookmarklet to show images inline
javascript:document.documentElement.innerHTML=document.documentElement.innerHTML.replace(/<a%20([^>]*)href=\"(http:\/\/[^\"]+)\.(jpg|JPG|png|PNG|gif|GIF)\"([^>]*)>([^<]+)<\/a>/g,%20"<a%20$1%20href=\"$2.$3\"$4>$5</a><img%20src=\"$2.$3\"%20style=\"border-style:solid;border-width:3px;\"%20width=\"600px\">");%20%20%20%20%20%20%20%20document.documentElement.innerHTML=document.documentElement.innerHTML.replace(/<a%20([^>]*)href=\"http:\/\/imgur.com\/([^\"\/\.]+)\"([^>]*)>([^<]+)<\/a>/g,%20"<a%20$1%20href=\"http://imgur.com/$2\"$3>$4</a><img%20src=\"http://i.imgur.com/$2.jpg\"%20style=\"border-style:solid;border-width:3px;\"%20width=\"600px\">").replace(/<a%20([^>]*)href=\"(http:\/\/www.quickmeme.com\/meme\/)([^\"\/]+)\/?\"([^>]*)>([^<]+)<\/a>/g,%20"<img%20src=\"http://i.qkme.me/$3.jpg\"%20style=\"border-style:solid;border-width:3px;\"%20width=\"300px\"><a%20$1%20href=\"$2$3\"$4>$5</a>").replace(/<a%20([^>]*)href=\"(http:\/\/qkme.me\/)([^\"\/\?]+)[^\"]*\"([^>]*)>([^<]+)<\/a>/g,%20"<img%20src=\"http://i.qkme.me/$3.jp
@bzerangue
bzerangue / mac-trim-support-non-apple-ssd.markdown
Created June 25, 2012 02:39
Enabling TRIM Support on Mac OS X with Non-Apple SSDs

How To: Enable TRIM with Non-Apple SSD

The guide breaks the process down into three steps, all performed via copying and pasting the code snippets through the terminal window. To launch a terminal window, open the Utilities folder inside the Applications folder and select terminal.

The first step makes a backup of the original IOAHCIBlockStorage file called IOAHCIBlockStorage.original. You will be prompted to enter in your system password when using the "sudo" command, since you are modifying system files. Copy and paste the code into the terminal window, a successful or uneventful response is a new blank terminal line.

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original

Next the code patches the IOAHCIBlockStorage file, removing the requirements that the SSD be made by Apple. Copy and paste t

@teabot
teabot / xa-datasources-spring.xml
Last active September 15, 2017 05:48
Example distributed XA transaction configuration for: Bitronix BTM, Spring, Hibernate, IBatis, Last Resource Commit
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util
@lavoiesl
lavoiesl / object.create.js
Created September 20, 2013 18:49
Javascript Object.create() polyfill
// http://jsperf.com/new-vs-object-create-including-polyfill
if (typeof Object.create !== 'function') {
Object.create = function(o, props) {
function F() {}
F.prototype = o;
if (typeof(props) === "object") {
for (prop in props) {
if (props.hasOwnProperty((prop))) {
F[prop] = props[prop];