Skip to content

Instantly share code, notes, and snippets.

@ckoye
ckoye / PhoneFormat.js
Created December 4, 2014 14:51
PhoneFormat.js for Titanium Mobile
/*
Modified version of
https://github.com/albeebe/phoneformat.js/blob/master/PhoneFormat.js
Made it Titanium-Mobile-ready by adding the exports for each function here.
http://www.phoneformat.com
*/
@schmuli
schmuli / Gulp and Bower Components.md
Last active December 29, 2017 15:44
Minify and Concat all bower components

This is an example gulpFile that can be used to minify and concat all bower components marked as dependencies. Also includes the bower.json and package.json files for the project.

The 'vendors' task will extract all bower components, using main-bower-files, but replaces any files that have a matching .min file that exists. Any unminified files are then minified using Uglify, and then all files are concatenated into a single vendors.js file.

The bower.json deliberately includes the SizzleStats dependency, as this component doesn't include a minified file.

@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@jcgregorio
jcgregorio / How_to_use.html
Last active July 17, 2023 14:44
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@iNaD
iNaD / request_no_curl.php
Last active February 29, 2024 09:37
Sending a GET/POST Request via PHP without CURL (fopen needs to be enabled)
<?php
$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
@xdamman
xdamman / install_ffmpeg_ubuntu.sh
Created July 2, 2014 21:03
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@staltz
staltz / introrx.md
Last active May 9, 2025 12:50
The introduction to Reactive Programming you've been missing
@StoneCypher
StoneCypher / repeater.jsx
Created April 16, 2014 18:44
This is how a React repeater control is made (housing html at https://gist.github.com/StoneCypher/10919111 )
/** @jsx React.DOM */
'use strict';
var RepeaterRow = React.createClass({
render: function() {
return <div>Repeater Row {this.props['data-ex']}</div>;
}
@tjmehta
tjmehta / javascript-object-to-querystring.js
Last active December 26, 2024 05:37
Object to Querystring - JavaScript, JS, JSON
function objectToQuerystring (obj) {
return Object.keys.reduce(function (str, key, i) {
var delimiter, val;
delimiter = (i === 0) ? '?' : '&';
key = encodeURIComponent(key);
val = encodeURIComponent(obj[key]);
return [str, delimiter, key, '=', val].join('');
}, '');
}
@mlouro
mlouro / gulpfile.js
Last active April 12, 2025 09:11
gulpfile.js with browserify, jshint, libsass, browserSync for livereload, image optimization and system notifications on errors
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var uglify = require('gulp-uglify');
var gulpif = require('gulp-if');
var exec = require('child_process').exec;
var notify = require('gulp-notify');