Skip to content

Instantly share code, notes, and snippets.

@ahsquared
ahsquared / Get query params
Last active May 19, 2020 18:18
Quick way to get query params in ES6
qp =()=> window.location.search.substr(1).split('&').reduce( (a, c) => Object.assign(a, (c.indexOf('=') !== -1 ? c : `${c}=`).split('=').reduce( (a, c) => ({[a]: c})) ) ,{})
export function setupMixins() {
_.mixin({
deepPluck: (obj, path) => {
if (_.isString(path)) {
path = path.split(".")
}
return _.reduce(path, function pluck(ret, ident) {
if (ident === "*") {
for (var key in ret) {
if (ret.hasOwnProperty(key)) {
function delegate(wrapper, selector, eventNames) {
return Rx.Observable.from(eventNames.split(",")).mergeMap(eventName => {
return Rx.Observable.fromEvent(
wrapper,
eventName.replace(/\s/g, ""),
function (e) {
return {event: e, delegate: e.target.closest(selector)};
});
}).filter(function (x) {
return x.delegate !== null;
@ahsquared
ahsquared / Trim file with FFMPEG
Created May 23, 2016 20:50
How to trim a file using FFMPEG on command line - times in HH:mm:ss
# -t optional without it will go to end
ffmpeg -ss [start-time] -i input.mp4 -c copy -t [clip-time] output.mp4
@ahsquared
ahsquared / rsync_using_identity.sh
Created November 30, 2015 19:44
rsync using identity file
rsync -azPv -e "ssh -i $HOME/.ssh/identity_file" ./ user@domain:/path/to/folder
var url1 = "//jsbin.com/dazogasipa/2.json?one",
url2 = "//jsbin.com2/dazogasipa/2.json?one";
function get(url, successHandler, errorHandler) {
var defer = $.Deferred();
$.ajax({
url: url,
method: 'GET',
dataType: 'json',
@ahsquared
ahsquared / index.html
Last active August 29, 2015 14:22 — forked from konsumer/index.html
Your serial ports:
<ul id="ports"></ul>
<script>
require('serialport').list(function(err, ports){
document.getElementById('ports').innerHTML = ports.map(function(port){
return '<li>' + port.comName + '</li>';
}).join('');
});
</script>
@ahsquared
ahsquared / sign(x) JS
Created April 16, 2014 13:59
Sign of a number in Javascript
From http://stackoverflow.com/questions/7624920/number-sign-in-javascript
Short excerpt
Use this and you'll be safe and fast
function sign(x) {
return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN;
}

The filter and zoom rules in the sample stylesheet above will apply a smoothing/blurring effect to text elements. In the sample stylesheet, these rules are applied to all headers, paragraphs, list items, and table cells, but in practice, you will want to tailor the application of the smoothing effect to only those elements rendering with significant aliasing.

Nota Bene: the filter appears to place an overflow: hidden-style block around the elements being smoothed, so do not apply these rules directly to elements that need to scroll, or which contain absolutely positioned elements that appear outside the boundaries of the element itself.