Skip to content

Instantly share code, notes, and snippets.

@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active July 3, 2024 02:22
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
#!/usr/bin/python
# A Wake on LAN program that allows you to send magic packets over the Internet
import socket, struct
class Waker():
def makeMagicPacket(self, macAddress):
# Take the entered MAC address and format it to be sent via socket
splitMac = str.split(macAddress,':')
# Pack together the sections of the MAC address as binary hex
@ghooghe
ghooghe / mime-message-to-eml.java
Created December 2, 2013 13:14
Write MimeMessage to .eml file
File eml = File.createTempFile("mailservice-output", ".eml");
OutputStream out = new FileOutputStream(eml);
msg.writeTo(out);
logger.debug("Temporary e-mail file written to {}", eml.getAbsolutePath());
IOUtils.closeQuietly(out);
@jnschulze
jnschulze / osx_ramdisk.sh
Last active February 5, 2024 13:48
Move Chrome, Safari and iTunes Cache to Ramdisk.
#!/bin/bash
# Size at the end is * 2048 where 2048 = 1 MB, so 1572864 = 768 MB
#DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://1572864`
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://2097152`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
CACHEDIR="/Volumes/RamDiskCache/$USER"
@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];
@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
@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

@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
@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"
@wadey
wadey / iterm2.zsh
Last active January 13, 2025 14:26
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"