Skip to content

Instantly share code, notes, and snippets.

@lukeholder
lukeholder / handlebars helper
Created November 8, 2011 01:02
handlebars get index array by helper
Handlebars.registerHelper('get', function(context, block) {
return block(context[block.hash['index']]);
});
// Use it
{{#get people index="1"}}
{{name}}
{{/get}}
@kd7lxl
kd7lxl / mythtv-transcode-x264.sh
Created December 9, 2011 00:36
MythTV transcode with x264
#!/bin/sh
set -e
# Adapted from a script at http://eternalvoid.net/tutorials/mythtv-autotranscode/
# Arguments
# $1 must be the directory/file to be transcoded.
# $2 must be the output directory / file name. The directory must be writeable by the mythtv user
# $3 must be chanid
# $4 must be starttime
@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@mystix
mystix / setup-php-dev.sh
Last active April 27, 2023 15:46
(OSX 10.7.x/10.8.x + Homebrew + nginx + mysql + php 5.4 + php-fpm + apc + xdebug) development environment
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install homebrew-dupes (required to install zlib, php54's dependency)
brew tap homebrew/dupes
# install nginx + mysql + php 5.4 + php-fpm + apc + xdebug
brew install nginx mysql
@tit
tit / getelementbyxpath.js
Last active December 27, 2021 10:45
Javascript => getElementByXPath
document.getElementByXPath = function(sValue) { var a = this.evaluate(sValue, this, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); if (a.snapshotLength > 0) { return a.snapshotItem(0); } };
document.getElementsByXPath = function(sValue){ var aResult = new Array();var a = this.evaluate(sValue, this, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);for ( var i = 0 ; i < a.snapshotLength ; i++ ){aResult.push(a.snapshotItem(i));}return aResult;};
document.removeElementsByXPath = function(sValue) { var a = this.evaluate(sValue, this, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for ( var i = 0 ; i < a.snapshotLength ; i++ ) { a.snapshotItem(i).parentNode.removeChild(a.snapshotItem(i)); } };
@bemre
bemre / tail_android_app_logs.sh
Created July 24, 2015 13:17
Tail android application's log
adb logcat | grep `adb shell ps | grep com.example.package | cut -c10-15`
@milesbxf
milesbxf / monzo-alertmanager-config.yaml
Last active July 17, 2024 12:51
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@ammmze
ammmze / ConverterDateAndJavaTime.java
Last active June 7, 2024 09:27
opencsv HeaderColumnNameAndOrderMappingStrategy
package com.example.csv;
import com.opencsv.bean.ConverterDate;
import com.opencsv.exceptions.CsvDataTypeMismatchException;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.util.Locale;
@csamsel
csamsel / h240.txt
Last active May 22, 2023 03:33
Switch HPE HBA H240 from raid mode to hba mode.
# So you want switch your HPE H240 controller to HBA mode for use with ESXi or UnRaid?
# online you'll find the follow command for HP controllers, like the P420i.
ssacli controller slot=0 modify hbamode=on
# For me, it was:
ssacli controller slot=255 modify raidmode=off
# while you are at it, you can also switch the power mode:
ssacli controller slot=255 modify powermode=minpower
@nogajun
nogajun / JYS-NS138.md
Last active March 10, 2024 17:14
JYS-NS138 Controler Instruction Sheet

Operating Instructions:

1.Mode and connection instructions

The Mode Switch:

Press Y + Home 2 seconds to enter the Bluetooth search mode, led1-led4 running horse flashes, and the LED channel corresponding to the successful connection remains on (Switching the assignment of the host organization); Synchronous state, or being paired with host connection: led1-led4 flashing horse;

Note: when the handle enters synchronization mode, it will automatically go to sleep if no synchronization is reached within 2.5 minutes.