Skip to content

Instantly share code, notes, and snippets.

View Sarfarazsajjad's full-sized avatar
🤠
playing django

Sarfaraz Hussain Sarfarazsajjad

🤠
playing django
View GitHub Profile
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
@Sarfarazsajjad
Sarfarazsajjad / app.js
Last active August 29, 2015 14:06 — forked from bobbydavid/app.js
var express = require('express')
, http = require('http')
, connect = require('connect')
, io = require('socket.io');
var app = express();
/* NOTE: We'll need to refer to the sessionStore container later. To
* accomplish this, we'll create our own and pass it to Express
* rather than letting it create its own. */
var sessionStore = new connect.session.MemoryStore();
// Require.js allows us to configure shortcut alias
require.config({
// The shim config allows us to configure dependencies for
// scripts that do not call define() to register a module
shim: {
'socketio': {
exports: 'io'
},
'underscore': {
exports: '_'
@Sarfarazsajjad
Sarfarazsajjad / Android Memory Management Notes.md
Created March 10, 2016 06:14 — forked from blixtra/Android Memory Management Notes.md
Notes taken while looking into memory issues on low-RAM devices

Android Memory Management

Android has a unique memory management model. Below, are the notes taken while we try to understand it thoroughly.

Activity Manager

Overview

The ActivityManager, among other things, is responsible for making sure that apps that are most important to the user and/or essential remain active. It does this by dynamically assigning values that roughly indicate the app's importance. When memory gets low these values are used to find the apps that need to be "trimmed." The memory from these "trimmed" apps is freed, making more available for the more important apps.

@Sarfarazsajjad
Sarfarazsajjad / states_hash.json
Created November 14, 2016 11:22 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@Sarfarazsajjad
Sarfarazsajjad / app.js
Created November 14, 2016 11:24 — forked from victorb/app.js
Easy AngularJS Directive for Google Places Autocomplete
var myApp = angular.module('myApp', []);
myApp.directive('googleplace', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, model) {
var options = {
types: [],
componentRestrictions: {}
};
@Sarfarazsajjad
Sarfarazsajjad / jspdf.plugin.text-align.js
Created September 14, 2017 14:38 — forked from Purush0th/jspdf.plugin.text-align.js
Text alignment for jsPDF 💥
(function (api, $) {
'use strict';
api.writeText = function (x, y, text, options) {
options = options || {};
var defaults = {
align: 'left',
width: this.internal.pageSize.width
}
@Sarfarazsajjad
Sarfarazsajjad / install-docker-linux-bionic.sh
Created September 8, 2019 08:07
Install Docker CE on Linux Ubuntu Bionic
#!/usr/bin/env bash
sudo apt update
sudo apt --yes install \
software-properties-common \
apt-transport-https \
ca-certificates \
curl
@Sarfarazsajjad
Sarfarazsajjad / fix-thinkpad-x230-linux-boot-issue.sh
Last active September 8, 2019 09:51
Thinkpad x230 Linux Boot issue fix for Ubuntu Bionic
# The problem can be solved as follows:
# Boot Ubuntu Live DVD/USB in testing mode and open terminal
# Run installation process without installing bootloader by:
# sudo ubiquity -b
# Press Continue testing after installation is over.
# Mount newly installed file system on /mnt:
@Sarfarazsajjad
Sarfarazsajjad / loopback-custom-routes.js
Created October 10, 2019 07:18
Loobback 3 custom routes
module.exports = function (app) {
// Install a "/ping" route that returns "pong"
app.get('/ping', function (req, res) {
res.send('pong');
});
// Express router middleware
var router = app.loopback.Router();
router.get('/ping_express', function (req, res) {
res.send('pongaroo');