Skip to content

Instantly share code, notes, and snippets.

@bencooling
bencooling / script.js
Created October 15, 2013 03:26
jsonp workflow
$(function(){
var xhr, $form = $('form');
function getResponse(data){
console.log(data);
}
function postForm(){
return $.ajax({
'dataType' : "jsonp",
@bencooling
bencooling / git-branching.md
Last active December 25, 2015 03:29
Useful Git commands

Branching

General

  • Master branch is automatically created by git init
  • When a branch is checked out, the HEAD is pointing to the branches latest commit
  • When multiple branches are merged back into a single branch, say the master, GIT will merge made by the 'recursive' strategy (GIT creates a common commit with multiple parents).

List branches

@bencooling
bencooling / fixes.css
Last active December 23, 2015 16:59
CSS: Cascading Stylesheets
/* Fix webkit blurry light text on dark background */
selector {
-webkit-font-smoothing: antialiased;
}
@bencooling
bencooling / snippets.php
Created September 16, 2013 23:10
PHP: Snippets
<?php
// Conditional Ajax vs regular HTTP response
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
echo json_encode($arr);
exit;
}
else {
// do something
}
@bencooling
bencooling / Guardfile
Last active December 20, 2015 22:09
Ruby, Gem & Guard
ignore /built\.js/
guard 'shell' do
watch(/script\/(.*).js/) { `node r.js -o build.js` }
end
guard 'shell' do
watch(/sass\/(.*).scss/) { `sass style/style.scss:style/style.css` }
end
@bencooling
bencooling / sqlite3.sh
Created July 23, 2013 11:53
sqlite3 commands
# Open database
sqlite3 mydata.db
# Select rows from table
SELECT * from memos;
# Delete table
DROP TABLE memos;
# Truncate table (Delete every row)
@bencooling
bencooling / READEME.md
Last active December 20, 2015 00:39
shell scripts

shell scripts

Various shell scripts

Class Generator

Includes the following files for creating class files in Windows environment:

  • classGenerator.php
  • classGenerator.bat
  • downloadLatestFiles.sh
@bencooling
bencooling / Gruntfile.js
Last active December 19, 2015 19:38
Node & NPM, Grunt.
(function () {
'use strict';
module.exports = function(grunt) {
// Plugins
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
@bencooling
bencooling / README.md
Last active December 19, 2015 09:29
PHP: boilerplate code for php libraries Swiftmailer, Illuminate

##php: boilerplate code for various php libraries Sample php code for php libraries found in packagist

  • Swiftmailer
@bencooling
bencooling / mixins.scss
Last active December 19, 2015 08:19
Sass: mixins
@mixin box-emboss($opacity, $opacity2){
box-shadow:white($opacity) 0 1px 0, inset black($opacity2) 0 1px 0;
}
/*
.box { @include box-emboss(0.8, 0.05); }
*/
@mixin letterpress($opacity){
text-shadow:white($opacity) 0 1px 0;