Skip to content

Instantly share code, notes, and snippets.

View adw0rd's full-sized avatar
:octocat:
I may be slow to respond.

Mikhail Andreev adw0rd

:octocat:
I may be slow to respond.
View GitHub Profile
-module(web_lager_handler).
-behaviour(gen_event).
-export([subscribe/1, unsubscribe/1]).
-export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2,
code_change/3]).
-export([remover_loop/0]).
@diyan
diyan / choosing_http_mock_library.md
Created December 18, 2012 12:04
Choosing HTTP mock library
-module(json_parser).
-export([decode_api/1]).
-record(api, {
status,
message,
timeout
}).
-record(api1, {
@marcelog
marcelog / logstashUDP.js
Last active April 12, 2018 20:19
quick UDP Logstash logging from nodejs
var util = require('util');
var dgram = require('dgram');
function logstashUDP(host, port, type, message, fields, callback) {
var client = dgram.createSocket('udp4');
var logObject = {
'@timestamp': (new Date).toISOString(),
type: type,
message: message,
fields: fields
@kennethreitz
kennethreitz / sync.py
Created October 10, 2010 19:08
GitHub Syncer. Clones or Pulls all GitHub repos (including watched list).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Kenneth Reitz's GitHub Syncer
This script uses the GitHub API to get a list of all forked, mirrored, public, and
private repos in your GitHub account. If the repo already exists locally, it will
update it via git-pull. Otherwise, it will properly clone the repo.
It will organize your repos into the following directory structure:
@tikseniia
tikseniia / get-posts.py
Created February 4, 2019 23:50
Get Instagram posts for tag
import requests
import time
import json
arr = []
end_cursor = '' # empty for the 1st page
tag = 'russia' # your tag
page_count = 5 # desired number of pages
for i in range(0, page_count):
url = "https://www.instagram.com/explore/tags/{0}/?__a=1&max_id={1}".format(tag, end_cursor)
r = requests.get(url)
@rcoup
rcoup / aws_usage.py
Created June 1, 2010 21:46
A script to query the Amazon Web Services (S3/EC2/etc) usage reports programmatically.
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
@avoine
avoine / gist:2912777
Created June 11, 2012 21:19
Bridge to send rsyslog logs to sentry (http://www.getsentry.com)
#!/usr/bin/env python
#
# Copyright 2012 Patrick Hetu <patrick.hetu@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@yannickl
yannickl / YLColor.swift
Last active September 16, 2023 03:55
Hex string <=> UIColor conversion in Swift
import Foundation
import UIKit
extension UIColor {
convenience init(hexString:String) {
let hexString:NSString = hexString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let scanner = NSScanner(string: hexString)
if (hexString.hasPrefix("#")) {
scanner.scanLocation = 1
@lorenzodifuccia
lorenzodifuccia / generate_instagram_enc_password.py
Created December 22, 2020 02:12
Encryption function used by Instagram (Browser App) to generate the 'enc_password' from PubKey (AES-GCM + SealedBox)
import base64
import struct
import datetime
import binascii
from urllib.parse import quote_plus
# pip install pycryptodomex
from Cryptodome import Random
from Cryptodome.Cipher import AES