Skip to content

Instantly share code, notes, and snippets.

View jperl's full-sized avatar

Jon Perl jperl

View GitHub Profile
@koba04
koba04 / .gitignore
Last active December 21, 2018 02:21
karma + mocha + browserify + babel + power-assert
node_modules/
@andrey-kazakov
andrey-kazakov / content_repeat.js.coffee
Created January 23, 2013 23:26
This AngularJS directive, when added to element, repeats it's content as many times as length of given array (almost like ng-repeat). The main difference is that DOM, once built, don't being changed on each $digest(). If you want to force the changing of repeated content, you should emit an event 'invalidateView' with (optionally) name of the sc…
angular
.module('ContentRepeat', [])
.directive 'contentrepeat', ($compile) ->
priority: 1000
terminal: true
compile: (element, attr, linker) ->
template = $compile(element.html())
element.empty()
(scope, self, attr) ->
@plurch
plurch / upsert.js
Created March 2, 2016 05:29
PostgreSQL 9.5 Upsert using Knex.js
exports.knex = require('knex')({
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
});
@Dref360
Dref360 / coordconv2d.py
Last active February 11, 2020 14:40
Un-scaled version of CoordConv2D
import keras.backend as K
import tensorflow as tf
from tensorflow.keras.layers import Layer
"""Not tested, I'll play around with GANs soon with it."""
from tensorflow.keras.layers import Conv2D
import numpy as np
class CoordConv2D(Layer):
@wylieconlon
wylieconlon / gist:1286265
Created October 14, 2011 04:40
Canvas animation with requestAnimationFrame and mouse tracking for games
var Animator = (function() {
var container,
canvas, ctx,
w, h,
offsetLeft, offsetTop,
lastX, lastY;
var init = function(el, options) {
container = el;
@jonathandixon
jonathandixon / Grunt-Cordova-CLI.md
Last active January 5, 2021 22:00
Using Grunt with a Cordova 3 project.

Grunt and Cordova 3

The advantages of using Grunt with Cordova:

  1. It simplifies working with the cordova cli.
  2. It provides a mechanism to copy platform customization to the platforms directory without having to commit the generated plugins and platforms directories to version control.
  3. It provides a way to watch resources and automatically run cordova commands.

Stack Overflow: .gitignore for PhoneGap/Cordova 3.0 projects - what should I commit?

export const GoogleApi = function(opts) {
opts = opts || {}
const apiKey = opts.apiKey;
const libraries = opts.libraries || [];
const client = opts.client;
const URL = 'https://maps.googleapis.com/maps/api/js';
const googleVersion = '3.22';
let script = null;
@badsyntax
badsyntax / find-unused-sass-variables.sh
Last active November 24, 2021 09:59 — forked from axelerator/Find unused variables in sass files
Find unused SCSS variables. Usage: `./find-unused-sass-variables.sh sassDir/`
#!/usr/bin/env bash
#
# Approach:
# 1. Find variable declaration in the form of "$my-var: anyvalue"
# 2. Loop through found variables and find occurrences of each variable in all sass files
# 3. Filter out vars that occurred only once
if [ -z "$1" ]; then
echo "Please specify a directory as the first argument."
exit 1
@jdmichaud
jdmichaud / Compressed UDP feed
Last active July 28, 2022 16:47
Create a virtual monitor and stream it
# Transmit a x264 compressed low latency feed using udp
server: gst-launch-1.0 videotestsrc is-live=true ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency byte-stream=true threads=1 key-int-max=15 intra-refresh=true ! rtph264pay ! udpsink host=%d port=9002
client: gst-launch-1.0 udpsrc port=9002 caps='application/x-rtp' ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false async=false
@niallo
niallo / gist:3109252
Created July 14, 2012 04:54
Parse Github `Links` header in JavaScript
/*
* parse_link_header()
*
* Parse the Github Link HTTP header used for pageination
* http://developer.github.com/v3/#pagination
*/
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}