Skip to content

Instantly share code, notes, and snippets.

View debuggerpk's full-sized avatar
🖖
whatever you seek is seeking you - Rumi

Yousuf Jawwad debuggerpk

🖖
whatever you seek is seeking you - Rumi
View GitHub Profile
@debuggerpk
debuggerpk / android_instructions.md
Created March 15, 2017 13:19 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@debuggerpk
debuggerpk / mr.py
Created January 5, 2017 23:30
Map Reduce Example
import itertools, json, operator
from string import capwords
from django.core import serializers
from django.db.models.manager import Manager, QuerySet
from django.utils import timezone as _tz
from dateutil.relativedelta import *
from dateutil import parser as dt_parser
@debuggerpk
debuggerpk / file-reader.js
Created January 5, 2017 23:25
angular directive example
'use strict';
export default function fileReader($q) {
'ngInject';
return {
restrict: 'E',
scope: {
label: '@',
accept: '@',
maxSize: '@',
@debuggerpk
debuggerpk / managers.py
Created January 5, 2017 23:20
Unique for M2M fields
from django.db.models import QuerySet, Manager
class BaseRankManager(Manager):
def rank(self, field_name, user_id, **kwargs):
"""
Gets unique items from the datebase based on the foreign key. this
queryset is ordered in reverse chronological order.
Args:
@debuggerpk
debuggerpk / cv.sql
Last active December 30, 2016 08:18
creating view
CREATE VIEW "lineitems_vista" AS
SELECT
id,
created_at,
updated_at,
shift_id,
itms.name as name,
quantity,
transaction_id,
itms.price as unit_price,
CREATE CONSTRAINT ON (n:Address) ASSERT n.node_id IS UNIQUE;
CREATE CONSTRAINT ON (n:Officer) ASSERT n.node_id IS UNIQUE;
CREATE CONSTRAINT ON (n:Entity) ASSERT n.node_id IS UNIQUE;
CREATE CONSTRAINT ON (n:Intermediary) ASSERT n.node_id IS UNIQUE;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///Addresses.csv" AS line
CREATE (n:Address {node_id: line.node_id })
SET n += line;
@debuggerpk
debuggerpk / topo.json
Created January 25, 2016 11:41
us-topo-.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@debuggerpk
debuggerpk / topo.json
Created January 25, 2016 11:41
us-topo-.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@debuggerpk
debuggerpk / dump.sql
Created January 21, 2016 20:19
correct pg_dump for amazon rds
SELECT exec('ALTER TABLE ' || quote_ident(s.nspname) || '.' || quote_ident(s.relname) || ' OWNER TO rds_superuser;')
FROM (
SELECT nspname, relname
FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid)
WHERE nspname in ('tiger','topology') AND
relkind IN ('r','S','v') ORDER BY relkind = 'S')
s;
@debuggerpk
debuggerpk / locate.js
Last active December 19, 2015 19:29
localte firefox extension
Components.utils.import("resource://gre/modules/AddonManager.jsm", null).AddonManager.getAllAddons(function (addons) {
alert(addons.filter(function (addon) {
return addon.type == "extension"
}).map(function (addon) {
return addon.name + ": " + addon.getResourceURI().spec
}).join("\n"))
});