Skip to content

Instantly share code, notes, and snippets.

#include <vector>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
typedef long long LL;
// base and base_digits must be consistent
const int base = 1000000000;
const int base_digits = 9;
@harshil93
harshil93 / gist:7324896
Last active December 27, 2015 12:19 — forked from ymotongpoo/gist:1342656
Some Important FFMPEG conversions
# using libfaac on Mac OS X 10.6.8
# -vn : not copying video
# -acodec : specify codec used in flv file
# -ac : channels. 1 is for mono, 2 is for stereo
# -ab : specify bitrate for output file (note that rate is not kbps but bps)
# -ar : sampling frequency (Hz)
# -threads: number of threads for encoding
# "-strict experimental" is necessary to use libfaac
ffmpeg -y -i xxxxxxxxxxx.flv -vn -acodec aac -ac 2 -ab 128000 -ar 44100 -threads 4 -strict experimental xxxxx.m4a
@harshil93
harshil93 / LRU cache
Created December 21, 2013 20:38
LRU cache implementation in C++11.
#include <iostream>
#include <unordered_map>
#include <list>
#include <stdexcept>
template <typename K, typename V>
class lru_cache {
private:
typedef std::pair<K, V> cache_entry;
typedef std::list<cache_entry> cache_list;

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
<!-- Respect Rollcall -->
<li><a href="http://www.alistapart.com/articles/">A List Apart &#8212; for website builders</a></li>
<li><a href="http://abstrusegoose.com/">Abstruse Goose &#8212; my favorite comic</a></li>
<li><a href="http://al3x.net/">Alex Payne &#8212; technology rambling</a></li>
<li><a href="http://dashes.com/anil/">Anil Dash &#8212; on culture, apple &amp; design</a></li>
<li><a href="http://weblogs.mozillazine.org/asa/">Asa Dotzler &#8212; on mozilla &amp; software</a></li>
<li><a href="http://www.azarask.in/blog/">Aza Raskin &#8211; on design &amp; firefox</a></li>
<li><a href="http://christophzillgens.com/en/">Christoph Zillgens &#8212; interface design</a></li>
<li><a href="http://cssremix.com/">CSS Remix &#8212; gorgeous designs</a></li>
<li><a href="http://css-tricks.com/">CSS Tricks</a></li>
@harshil93
harshil93 / Fast Input Output C++.cpp
Last active August 29, 2015 14:13
FAST OUTPUT IS ENABLED ONLY WHEN 'ONLINE_JUDGE' IS DEFINED
// FAST OUTPUT IS ENABLED ONLY WHEN 'ONLINE_JUDGE' IS DEFINED
#include <cstdio>
#include <iostream>
using std::string;
static struct IO {
char tmp[1 << 10];
// fast input routines
@harshil93
harshil93 / _.md
Last active August 29, 2015 14:17 — forked from klange/_.md

Since this is on Hacker News...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later).
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • They're all while loops because shut up, you're overthinking a joke.
@harshil93
harshil93 / SampleModel.js
Created June 8, 2015 07:11
Retrieving / Getting the current user id in a remote method in strongloop's loopback framework.
var loopback = require('loopback');
module.exports = function(SampleModel) {
// Returns null if the access token is not valid
function getCurrentUserId() {
var ctx = loopback.getCurrentContext();
var accessToken = ctx && ctx.get('accessToken');
var userId = accessToken && accessToken.userId;
return userId;
@harshil93
harshil93 / hn_seach.js
Last active September 2, 2015 07:13 — forked from kristopolous/hn_seach.js
hn job query search
function query() {
var
total = 0, shown = 0,
// HN is done with very unsemantic classes.
job_list = Array.prototype.slice.call(document.querySelectorAll('.c5a,.c00,.c9c,.cdd,.c73,.c88')),
query_list = Array.prototype.slice.call(arguments);
// This traverses up the dom stack trying to find a match of a specific class
function upTo(node, klass) {
if (node.className === klass) {
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
Disable-UAC