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
@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--";
@2b3pro
2b3pro / ffmpeg_merge_videos_in_folder.md
Last active May 12, 2021 21:48
[Automator] Quick Action to Concatenate Videos in a Folder for YT-ready Upload

Q: How do I combine individual video clips into one movie file for upload to YouTube using ffmpeg?

The following assumes you have ffmpeg installed on your Mac. If you need to install it, please use Homebrew.

The settings for encoding for YouTube with ffmpeg can be found here and here.

There is no error checking here. It assumes that there are videos in the folder, and that they have mp4 extensions.


@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
@ozen
ozen / Selenium PhantomJS Python Header.py
Last active September 6, 2021 05:12
How to set request headers when using Selenium Python with PhantomJS driver
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) ' \
'AppleWebKit/537.36 (KHTML, like Gecko) ' \
'Chrome/39.0.2171.95 Safari/537.36'
driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)
@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.

@jaysonrowe
jaysonrowe / FizzBuzz.py
Created January 11, 2012 03:05
FizzBuzz Python Solution
def fizzbuzz(n):
if n % 3 == 0 and n % 5 == 0:
return 'FizzBuzz'
elif n % 3 == 0:
return 'Fizz'
elif n % 5 == 0:
return 'Buzz'
else:
return str(n)
@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),
@freem
freem / twitter-killjunk.js
Last active December 28, 2022 22:22
disabling extraneous twitter features
/* NOTICE: THIS WAS MADE BACK IN 2017, OF COURSE IT'S NOT GOING TO WORK WELL NOW THAT TWITTER'S FUCKED THINGS UP */
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
[data-component-context="suggest_recap"],
[data-component-context="suggest_who_to_follow"],
[data-component-context="suggest_activity"],
[data-component-context="suggest_activity_tweet"],
[data-component-context="suggest_recycled_tweet_inline"],
[data-component-context="suggest_recycled_tweet"]{
@kbravh
kbravh / adjust-cron-for-dst.py
Last active March 26, 2023 17:14
Adjust cron events for DST (Daylight Savings Time) automatically with a Python function to be run on AWS Lambda.
from datetime import datetime
import pytz
import boto3
# define our CloudEvents client
client = boto3.client('events')
# Let's grab our current time in GMT and convert it to local time (US Central)
utc_time = datetime.utcnow().replace(tzinfo=pytz.utc)
# Set your timezone here! See timezones here: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568