Skip to content

Instantly share code, notes, and snippets.

<!-- SEO / Google -->
<meta name="author" content="Author name here....">
<meta name="description" content="Description text here.....">
<link rel="canonical" href="URL here...">
<!-- Social: Twitter -->
<!-- After inserting META need to validate at https://dev.twitter.com/docs/cards/validation/validator -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@8bit_code">
<meta name="twitter:creator" content="8bit_code">
@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;
@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
@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"]{
@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),
@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)
@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.

@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)
@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
@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.