Skip to content

Instantly share code, notes, and snippets.

@jpbochi
jpbochi / underscore_groupby_with_selector.js
Created September 26, 2012 02:34
underscore.js extended groupBy with value selector
// The code below will extend underscore.js adding the groupByAndMap function.
// groupByAndMap works like the regular groupBy, but it accepts an optional third "selector" argument.
// The 'selector' is used to select values inside each group.
// As usual in underscore, you can either pass a function or a string with the name of an attribute you want.
// groupByAndMap is useful when you don't want the key to be present in the values inside the group.
// Also, it completely covers the groupBy functionality because the last argument is optional.
// If you want, you can replace groupBy instead of defining a new function.
_.mixin({
groupByAndMap: function(list, keySelector, valueSelector) {
@mogya
mogya / gist:3781468
Created September 25, 2012 12:24
An idea to convert dp to/from pixel on TitaniumMobile Android
// convert dp to pixel.
function dpToPixel(dp) {
return ( parseInt(dp) * (Titanium.Platform.displayCaps.dpi / 160));
}
// convert pixel to dp.
function pixelToDp(px) {
return ( parseInt(px) / (Titanium.Platform.displayCaps.dpi / 160))+'dp';
}
@iMagdy
iMagdy / node_apache.apacheconf
Last active February 25, 2020 00:46
This virtualhosts snippet will make your nodejs app run on the traditional port 80, so mynodeapp.com:3000 will simply work on mynodeapp.com without adding :3000. it's that simple :) remember to enable apache modules proxy and proxy_http ($ sudo a2enmod proxy && sudo a2enmod proxy_http)
<VirtualHost *:80>
ServerAdmin isl@m.magdy
ServerName js.io
ServerAlias js.io
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
@izzygld
izzygld / repeater-meta.php
Created June 25, 2018 14:22
Hooking up ACF repeater fields to the shema.
//acf stats repeater
array (
'key' => 'field_5a27ee3a83076',
'label' => 'Stats',
'name' => 'stats',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
@thibmaek
thibmaek / deploy-expo-ios.sh
Created June 21, 2018 21:43
CD for Expo RN applications
#! /usr/bin/env bash
set -e
# This is based on the expo blogpost:
# https://blog.expo.io/automating-standalone-expo-app-builds-and-deployments-with-fastlane-exp-and-exptool-9b2f5ad0a2cd
# Publish `production` release to Expo
function publish_expo() {
# Log into Expo when running in CI
# Locally you should already be logged in

Basic Moves

Function Shortcut
Move back one character Ctrl + b
Move forward one character Ctrl + f
Delete current character Ctrl + d
Delete previous character Backspace
Undo Ctrl + -
@tomazzaman
tomazzaman / hhvm.conf
Last active May 13, 2021 19:44
Monit configurations for commonly used services
check process hhvm with pidfile /var/run/hhvm/pid
group hhvm
start program = "/usr/sbin/service hhvm start" with timeout 60 seconds
stop program = "/usr/sbin/service hhvm stop"
if failed unixsocket /var/run/hhvm/hhvm.sock then restart
if mem > 400.0 MB for 1 cycles then restart
if 5 restarts with 5 cycles then timeout
if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) {
//is IE 11 or below
}
@lumpysimon
lumpysimon / .gitignore
Last active April 5, 2022 00:37
A .gitignore file for WordPress that ignores pretty much everything except for the specified plugin(s), theme(s) and mu-plugins folder
# .gitignore file for WordPress that ignores everything except:
#
# - .gitignore
# - favicon.ico
# - wp-config.php
# - everything in mu-plugins
# - my-plugin
# - my-theme (except for .sass-cache)
#
# based on https://gist.github.com/jdbartlett/444295
@nickcernis
nickcernis / mailchimp-popup-for-wordpress.md
Last active July 28, 2022 14:49
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.