Skip to content

Instantly share code, notes, and snippets.

View czterystaczwarty's full-sized avatar

Tomasz Szopiński czterystaczwarty

View GitHub Profile
@czterystaczwarty
czterystaczwarty / extract_colors.sh
Last active August 29, 2015 14:00
Extracts colors with CSS, sort and remove duplicates.
# Extracts colors with CSS, sort and remove duplicates.
egrep -o 'rgba\([[:digit:],\.\s\ ]+\)|#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})' style.css | sed 's/ *//g' | xargs -n1 | sort -u
#!/bin/bash
AUTHOR=$(git config user.name)
DATE=$(date +%F)
git log --no-merges --format="%cd" --date=short --no-merges --author="$AUTHOR" --all | sort -u -r | while read DATE ; do
if [ $NEXT != "" ]
then
echo
echo [$NEXT]
fi
GIT_PAGER=cat git log --no-merges --format=" %s" --since=$DATE --until=$NEXT --author="$AUTHOR" --all
{"title":"test video","description":"hsjfav","screen":"http://amway.apide.com/de/media/screen/2-amway-german-test-video.jpeg","file":"http://amway.apide.com/de/media/view/4.mp4","duration":"01:25","brand":"Amway german","views":2,"rating":0}
@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
@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 / 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 / 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;
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
@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'"
<ul>
<li><button class="user-status online" data-to-hide="^ul">Online</button></li>
<li><button class="user-status away" data-to-hide="^ul">Away</button></li>
<li><button class="user-status dont-disturb" data-to-hide="^ul">Do not disturb</button></li>
<li><button class="user-status invisible" data-to-hide="^ul">Invisible</button></li>
<li><button class="user-status signout" data-to-hide="^ul">Sign out</button></li>
</ul>