Skip to content

Instantly share code, notes, and snippets.

View assem-ch's full-sized avatar

Assem Ch assem-ch

View GitHub Profile
@jacobian
jacobian / models.py
Created February 15, 2011 18:11
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
@paulmillr
paulmillr / active.md
Last active June 10, 2024 18:10
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user => user.followers > 1000)
@alexmic
alexmic / problem_79.py
Created October 5, 2013 22:24
Project Euler problem #79.
from collections import defaultdict, deque
def find_number_universe(keylog):
numbers = set()
for attempt in keylog:
for num in attempt:
numbers.add(num)
return numbers
@arunoda
arunoda / gist:7790979
Last active February 16, 2024 14:05
Installing SSHPass

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

@mattseymour
mattseymour / django-secret-keygen.py
Last active September 8, 2022 23:47
Django secret key generator
"""
Pseudo-random django secret key generator.
- Does print SECRET key to terminal which can be seen as unsafe.
"""
import string
import random
from __future__ import print_function
@rgrove
rgrove / gist:b260e21a8db776bde91b
Created June 20, 2014 17:17
Open source guilt

So here's the thing: I've been releasing my code as open source for nearly 15 years. When I write something for me, I release it for other people. Inevitably, I eventually stop needing that thing, so I stop spending time on it.

When a PR comes in for a project I haven't actively worked on in a while, handling that PR requires me to reacquaint myself with the old code, remember how and why I made certain choices, consider whether accepting the PR would create any new maintenance burdens for me or would potentially introduce problems for users who've been using a stable and unchanged program for years now. If I decide it's worthwhile, then I have to test it. Maybe my old project has tests; maybe it doesn't. If it doesn't, that means I have to get it running and test manually.

More often than not, a PR will contain questionable code or inconsistent formatting or something else that requires some back and forth with the author. This takes time out of my day (often out of several days due to the async nature of

@beeftornado
beeftornado / nginx-conf
Last active January 18, 2024 19:54
Nginx reverse proxy for Sentry (github.com/getsentry/sentry). I removed some personal information and replaced it with <UPPERCASE> so look closely. Some key information in the sentry settings - SENTRY_URL_PREFIX, FORCE_SCRIPT_NAME, and ALLOWED_HOSTS. The rest of that is pretty standard.
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
@suzuken
suzuken / ua.js
Last active September 9, 2020 15:22
experimental UDF on Bigquery with https://github.com/woothee/woothee-js.
var root = this;
// embed: dataset, util, browser, mobilephone, crawler, appliance, misc, woothee
// GENERATED from dataset.yaml at Thu Aug 13 14:22:28 JST 2015 by tagomoris
// Snapshot from package.json
var package_info = {"name":"woothee","version":"1.2.0","description":"User-Agent string parser (js implementation)","main":"./release/woothee","devDependencies":{"mocha":">= 1.7.0","chai":">= 1.3.0","js-yaml":">= 1.0.3","should":"~1.2.2"},"scripts":{"test":"make test"},"repository":{"type":"git","url":"https://github.com/woothee/woothee-js"},"author":"tagomoris","license":"Apache v2"};
var dataset = {};
(function(){
@heitorlessa
heitorlessa / presign_url.py
Created January 11, 2017 16:11
Quick and dirty S3 Presign URL using Python Boto3 and Click
import boto3
import click
@click.command()
@click.argument("bucket")
@click.argument("key")
@click.option("-e", "--expiration", default=3600, type=int, help="How long this presigned URL will live for")
def presign_s3(bucket, key, expiration):
""" Simple utility to generate presigned URL on S3 (Default 1 hour expiration)
@silentsudo
silentsudo / ElasticSearch.postman_collection
Created January 11, 2017 18:24
Elastic search postman collection
{
"id": "0c45385d-7359-15da-b7c3-1b605de97d51",
"name": "ElasticSearch",
"description": "Elastic Search indexing searching and more...",
"order": [
"d87d6360-248b-7cbb-df59-a5c90f8f6e50",
"4f44462b-7d52-44c3-baad-1ca171aab0c0",
"e9efbbd2-7dad-3e42-9c34-e557090e774a",
"5c47039e-b910-4e5f-4e34-e11866efff89",
"91d64fe8-acc6-b245-30fd-0149c157b285",