Skip to content

Instantly share code, notes, and snippets.

@babo
babo / lambda.py
Created December 17, 2015 11:55
Simple AWS lambda job to create an SQS event for each S3 events.
#!/usr/bin/env python
import argparse
import logging
try:
from urllib import splittype
except ImportError:
from urllib.parse import splittype
import boto3
@R41D3NN
R41D3NN / get-ipinfo.js
Last active May 21, 2023 00:51
Javascript for retrieving IP Address info using ipinfo.io API via AJAX.
var GetIpInfo = function(ipAddr) {
var info = null;
var infoUrl = "http://ipinfo.io/" + ipAddr;
$.ajax({
url: infoUrl,
type: 'GET',
dataType: 'json',
async: false,
success: function(data) {
info = data;
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active April 25, 2024 04:16
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@IceCreamYou
IceCreamYou / percentile.js
Last active November 17, 2022 01:54
Utility functions to calculate percentiles and percent ranks in a JavaScript array.
// Returns the value at a given percentile in a sorted numeric array.
// "Linear interpolation between closest ranks" method
function percentile(arr, p) {
if (arr.length === 0) return 0;
if (typeof p !== 'number') throw new TypeError('p must be a number');
if (p <= 0) return arr[0];
if (p >= 1) return arr[arr.length - 1];
var index = (arr.length - 1) * p,
lower = Math.floor(index),
@lykmapipo
lykmapipo / phantomjs-facebook-update.js
Last active August 30, 2018 18:52 — forked from ariefbayu/phantomjs-facebook-update.js
facebook status update using phantomjs
var page = new WebPage();
//spoof it as opera mini, to get the mobile page working properly
page.settings.userAgent = "Opera/9.80 (J2ME/MIDP; Opera Mini/6.5.26955/27.1407; U; en) Presto/2.8.119 Version/11.10";
function doLogin(){
page.evaluate(function(){
var frm = document.getElementById("login_form");
frm.elements["email"].value = "--enter-your-email--";
@moonmilk
moonmilk / dreamhostpython.md
Last active August 12, 2022 16:15
trying to figure out useful info for running python on dreamhost shared hosting - intended for twitter bot makers

python for botmakers, on dreamhost shared hosting

On a shared hosting service like dreamhost, how do you get your twitter bot up and running? Problems:

  • where should I put my script?
  • you can't install python modules like tweepy (for twitter access) because you don't have root permission
  • once you get that solved, how do you run your script? cron?

I'm still figuring this stuff out myself, so nothing is clear as it should be. Hope this page will be a resource that will improve over time.

@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@staltz
staltz / introrx.md
Last active May 6, 2024 01:44
The introduction to Reactive Programming you've been missing
@myrtleTree33
myrtleTree33 / install-node-pi.sh
Last active March 8, 2024 22:37
Install Node JS in 30 seconds for Raspberry Pi / ARM
#!/bin/bash
## Check for versions compiled with ARM at http://nodejs.org/dist/
## Inspired by http://oskarhane.com/raspberry-pi-install-node-js-and-npm/
## Fill in the Node Version here:
##########################################################################
NODE_VERSION="v0.10.21"
@dgym
dgym / comic.py
Created May 7, 2013 12:15
A comic like effect using OpenCV
import sys
import numpy
import cv2
def comic(img):
# do edge detection on a grayscale image
gray = cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY)
edges = cv2.blur(gray, (3, 3)) # this blur gets rid of some noise