Skip to content

Instantly share code, notes, and snippets.

@ahsquared
ahsquared / jquery.styleRadioButtons
Last active December 22, 2015 11:39
select radios to style: $(':radio').styleCheckboxes();
// select radios to style: $(':radio').styleCheckboxes();
$.fn.styleRadioButtons = function() {
$(this).each(function(index) {
if (!$(this).prev("a").hasClass('radio-styled')) {
var group = $(this).attr('name');
$(this).before('<a href="#radio_' + index + '" class="radio-styled" id="radio_' + index +
'" rel="rg-' + group + '"></a>')
.css({
position: 'absolute',
left: -1,

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.

@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;
}
@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>
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 / 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
@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
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;
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)) {