Skip to content

Instantly share code, notes, and snippets.

// Write a general-purpose reducer that excludes items based on a predicate
function excludeReducer(predicate) {
return function(newArray, item) {
return predicate(item) ? newArray : newArray.concat(item);
}
}
function excludeIdReducer(id) {
return excludeReducer(function(item) {
@noeticpenguin
noeticpenguin / pesudocode.html
Created January 8, 2014 20:28
bootstrapping an ng app after manual remoting calls. Jason, Essentially, you want to do this:
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<body>
Hello {{'World'}}!
<script src="http://code.angularjs.org/angular.js"></script>
<script>
angular.element(document).ready(function() {
RemoteJSCall.then(function(results){
//manipulate results if needed.
//do whatever with results to get app ready
angular.module('myApp').config(['$httpProvider', function($httpProvider) {
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot');
}
@font-face {
font-family: 'icomoon';
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg6v8ywAAAC8AAAAYGNtYXDgfOaMAAABHAAAAERnYXNwAAAAEAAAAWAAAAAIZ2x5ZlRMFxoAAAFoAAA6WGhlYWQASAk3AAA7wAAAADZoaGVhB8ID+wAAO/gAAAAkaG10eOIADMUAADwcAAAA6GxvY2GdD5AIAAA9BAAAAHZtYXhwAEMBLQAAPXwAAAAgbmFtZUQXtNYAAD2cAAABOXBvc3QAAwAAAAA+2AAAACAAAwQAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAACDmAgPA/8D/wAPAAEAAAAAAAAAAAAAAAAAAAAAgAAAAAAACAAAAAwAAABQAAwABAAAAFAAEADAAAAAIAAgAAgAAACDgNOYC//8AAAAg4ADmAP///+EgAho3AAEAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQBRABEDrgNuAFMAAAEuASIGBwEOARQWFx4BMjY3AT4BNCYnLgEiBg8BDgEUFhceATI2PwE+ATIWFx4BFAYHAQ4BIiYnLgE0NjcBPgEyFhceARQGDwEeAxc3PgE0JicDrihmamYp/isoKCgoKWZqZigBIBkZGRkZP0I/GbQKCgoKCRcYFwm1BhAQEAYGBgYG/uAWNzk3FhYWFhYB1RY3OTcWFhYWFgQLEQwHAS4pKSkpA24pKSkp/isoZmpmKSgoKCgBIBk/Qj8ZGRkZGbUJFxgXCQoKCgq0BgYGBgYQEBAG/uEWFhYWFjc5NxYB1RYWFhYWNzk3FgQPICIjEi4pZmpmKAA
if (
and (
YEAR(Date_Start__c) == YEAR(TODAY()),
IF(
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7)
) ==
IF(
{ "body" :
{
"messageSegments" : [
{
"type": "mention", // <== type = mention for @mentions
"id":"005D0000001LL8YIAW" <== user id for the @mention
},
{
"type": "link",
"href":"http://www.google.com"
71: # create an ad
72: # create_ad(oid, cid, n, mpid, sd, ed, d, vinit, vaud, vlang, pltyp, ct, pdev, arc, params = {})
73: gmt_start = DateTime.parse("2014-1-26").to_time.to_i #+ offset_in_seconds
74: gmt_end = DateTime.parse("2014-1-31" + 'T23:59:00').to_time.to_i
75: new_add = mash(@adap.create_ad("6482","44810", "Best Test Ad Ever!", "33", gmt_start, gmt_end, "15", "AUTO", "YES", "ENGLISH", "GAME_PLAYER", "PRO", "ANY", "VIDEO"))
=> 76: binding.pry
77: end
78: end
[1] pry(#<AdapMiddleware::App>)> gmt_start
@noeticpenguin
noeticpenguin / Gruntfile.js
Created February 11, 2014 20:39
gruntfile
module.exports = function(grunt) {
grunt.initConfig({
jasmine: {
proposalPlus: {
// Include paths for both the local user, if we're in dev mode, as well as share mode
src: 'pp_ngApp_' + process.env.USER + '.resource/pp_ngApp/**/*.js, pp_js' + process.env.USER + '.resource/pp_js/**/*.js, pp_ngApp/pp_ngApp/**/*.js, pp_js/pp_js/**/*.js',
options: {
// Include path for Jasmine spec files, including both dev and share path versions.
specs: 'pp_test_' + process.env.USER + '.resource/pp_test/**/*spec.js, pp_test/pp_test/**/*spec.js',
}
@noeticpenguin
noeticpenguin / Gruntfile.js
Last active August 29, 2015 13:56
gruntfile
module.exports = function(grunt) {
grunt.initConfig({
jasmine: {
proposalPlus: {
// Include paths for both the local user, if we're in dev mode, as well as share mode
src: ['pp_js' + process.env.USER + '.resource/pp_js/**/*.js',
'pp_ngApp_' + process.env.USER + '.resource/pp_ngApp/**/*.js',
'pp_js/pp_js/**/*.js',
'pp_ngApp/pp_ngApp/**/*.js'
],

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash