Skip to content

Instantly share code, notes, and snippets.

View czterystaczwarty's full-sized avatar

Tomasz Szopiński czterystaczwarty

View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
activity: undefined,
periods: Ember.A(),
duration: Ember.computed.sum('periods'),
lastResumeTimestamp: undefined,
isStarted: Ember.computed.notEmpty('periods'),
isRunning: false,
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@czterystaczwarty
czterystaczwarty / pre-commit.sh
Created March 8, 2016 08:43 — forked from chadmaughan/pre-commit.sh
A git pre commit hook that runs the test task with the gradle wrapper
#!/bin/sh
# this hook is in SCM so that it can be shared
# to install it, create a symbolic link in the projects .git/hooks folder
#
# i.e. - from the .git/hooks directory, run
# $ ln -s ../../git-hooks/pre-commit.sh pre-commit
#
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git commit --no-verify'
@czterystaczwarty
czterystaczwarty / .gitconfig
Created September 18, 2015 08:35
List branches by date
recentbranches = "!sh -c \"git for-each-ref --sort='committerdate' --format='%(color:green)%(committerdate:short) %(color:yellow)%(refname)' refs/heads | sed -e 's-refs/heads/--'\""
rb = "!sh -c 'git recentbranches'"
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
@czterystaczwarty
czterystaczwarty / once.js
Created September 16, 2015 21:37
The `once` function ensures a given function can only be called once, thus prevent duplicate initialization!
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
return result;
@czterystaczwarty
czterystaczwarty / poll.js
Created September 16, 2015 21:34
Check for desired state at intervals.
function poll(fn, callback, errback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if(fn()) {
callback();
}
// If the condition isn't met but the timeout hasn't elapsed, go again
@czterystaczwarty
czterystaczwarty / debounce.js
Last active September 16, 2015 20:38
The `debounce` function will not allow a callback to be used more than once per given time frame. This is especially important when assigning a callback function to frequently-firing events.
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
@czterystaczwarty
czterystaczwarty / edit_xml.sh
Created August 21, 2015 10:27
Replace tag in xml and push to stodout
xmlstarlet edit -u '//requestNumber' -v '1234567' /tmp/rejectCustomer_pl.soap