Skip to content

Instantly share code, notes, and snippets.

function qsort(arr) {
if (arr.length < 2) {
return arr;
}
var pivot = arr[0];
var less = arr.slice(1).filter(x => x <= pivot);
var greater = arr.slice(1).filter(x => x > pivot);
return qsort(less).concat(pivot).concat(qsort(greater));
}
function rlEncode(str) {
var strs = str.split('');
var a1 = strs.reduce((acc, i) => {
if (i === acc.cur) {
return {
cur: i,
count: acc.count+1,
s: acc.s
}
} else {
function selectionSort(arr) {
const sortedArr = [];
const len = arr.length;
for (var i = 0; i < len;i++) {
const smallestIndex = getSmallestIndex(arr);
sortedArr.push(arr[smallestIndex]);
arr.splice(smallestIndex, 1)
}
return sortedArr;
}
@marufsiddiqui
marufsiddiqui / Amazon Offerlisting.js
Created January 7, 2017 21:36
Amazon Offerlisting UserScript
// ==UserScript==
// @name Amazon Offerlisting
// @version 1.0.6
// @description Add CamelCamelCamel graph, link to Amazon product pages.
// @author Andrew Metzger
// @namespace http://static.nerdoncloud.com/userscripts/
// @include https://www.amazon.de/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// ==/UserScript==
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@marufsiddiqui
marufsiddiqui / Draggable.js
Created June 27, 2016 14:53 — forked from Rob-ot/Draggable.js
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
@marufsiddiqui
marufsiddiqui / README.md
Created June 8, 2016 08:40 — forked from rauchg/README.md
require-from-twitter

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

@marufsiddiqui
marufsiddiqui / marketplace-contestant.html
Created April 11, 2016 14:25
marketplace-contestant.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!-- start coded_template: id:3730118823 path:custom/email/shopify/marketplace-contestant.html --><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" style="-webkit-font-smoothing:antialiased !important; -moz-osx-font-smoothing:grayscale !important; text-rendering:optimizeLegibility !important; font-smoothing:antialiased !important"><head>
<meta name="viewport" content="width=device-width">
<meta charset="utf-8">
<title>Good luck in our Marketplace contest!</title>
<meta name="description" content="">
<script type="text/javascript" src="https://static.hsstatic.net/jquery-libs/static-1.1/jquery/jquery-1.7.1.js"></script>
@marufsiddiqui
marufsiddiqui / weekly-digest-new-mobile-features-4-tips-on-typesetting-better-design-dev.html
Created April 11, 2016 14:24
weekly-digest-new-mobile-features-4-tips-on-typesetting-better-design-dev
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!-- start coded_template: id:2279653568 path:custom/email/weekly_digest/weekly_digest.html --><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta name="viewport" content="width=device-width">
<meta charset="utf-8">
<title>Weekly digest: New mobile features | 4 tips on typesetting UIs | Better design-dev collaboration | Design Snack #3</title>
<meta name="description" content="Weekly digest 4.6.2015–4.10.2015 | InVision
Get 4 tips on setting type in your UIs, 5 ways to help designers and devs collaborate in responsive web design projects, and 1 smarter way to consolidate your Photoshop files">
<script type="text/javascript" src="https://static.hsstatic.net/jquery-libs/static-1.1/jquery/jquery-1.7.1.js"></script>
<script type="text/javascript">hsjQuery = window['jQuery']</script>