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})) ) ,{})
@ahsquared
ahsquared / Compress JPG with ImageMagick
Last active March 7, 2019 19:04
Compress JPG with ImageMagick
convert -strip -interlace Plane -sampling-factor 4:2:0 -define jpeg:dct-method=float -quality 70% source.jpg output.jpg
@ahsquared
ahsquared / Queueing with RxJS
Last active December 1, 2016 14:59
Set up a queue of Observables with RxJS
stream$.flatMap(array => {
let observablesArray = array.map(arrayItem => {
// map over array returning observables - this can be nested and flattened
return Rx.Observable.fromPromise(promiseFunction(arrayItem))
// whatever other rx-y things you need to do
.retry(2)
// what do we really want to do with these errors
.catch(e => {
return Rx.Observable.of({
errorStatus: true,
@ahsquared
ahsquared / bash_profile
Last active February 1, 2017 16:22
bash profile for OSX
### MY ALIASES ###
##################
# git command autocompletion script
# source ~/bin/git-completion.bash
# clear screen
alias cls='clear'
# git commands simplified
@ahsquared
ahsquared / Hex pack shader
Last active March 23, 2017 13:59
Hex packing shader for shadertoy
float hex(vec2 p) {
p.x *= 0.57735*2.0;
p.y += mod(floor(p.x), 2.0)*0.5;
p = abs((mod(p, 1.0) - 0.5));
return abs(max(p.x*1.5 + p.y, p.y*2.0) - 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 pos = fragCoord.xy;
vec2 p = pos/20.0;
@ahsquared
ahsquared / sequelize-schema-file-generator.js
Created July 15, 2018 02:01 — forked from francolaiuppa/sequelize-schema-file-generator.js
Automatically generates migration files from your sequelize models
'use strict';
//////////////////////////////////
// How to use?
// 1. Create `sequelize-schema-file-generator.js` in your app root
// 2. Make sure you've ran the `sequelize init` before (It should create `config`,`seeders`,`migrations` folders).
// 3. Update `DATABASE_DSN` below to match your connection string (works with any database adapter that Sequelize supports)
// 4. Run it with `node sequelize-schema-file-generator.js`
// 5. Review the generated migrations inside of the `migrations` folder.
//////////////////////////////////
@ahsquared
ahsquared / jQuery-tap.js
Created January 23, 2019 16:00 — forked from subhaze/jQuery-tap.js
Probably a more sane way to do this, but, here's a x-device click/tap event; It works with event delegation as well.
jQuery.event.special.tap = {
add: function(handleObj){
var $this = $(this);
var touchMoved = false;
var touched = false;
var touchesHandler = function(e){
if(e.type === 'touchstart'){
touchMoved = false;
touched = true;
}else if(e.type === 'touchmove'){
" Make IE Better Compatible "
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
======================================================
IE6 Only
==================
_selector {...}

Keybase proof

I hereby claim:

  • I am ahsquared on github.
  • I am ahsquared (https://keybase.io/ahsquared) on keybase.
  • I have a public key ASDJc6AqtXFR9nVJAjgDbiMFXhVS711QfKGtvlY0wflafgo

To claim this, I am signing this object:

@ahsquared
ahsquared / cloudSettings
Created January 25, 2020 02:07
cloudSettings
{"lastUpload":"2019-08-14T20:33:56.411Z","extensionVersion":"v3.4.1"}