Skip to content

Instantly share code, notes, and snippets.

@misja
misja / tweepy_status_monkeypatch.py
Created August 31, 2011 12:30
Set json data as an attribute in a tweepy Status object.
import tweepy
import json
@classmethod
def parse(cls, api, raw):
status = cls.first_parse(api, raw)
setattr(status, 'json', json.dumps(raw))
return status
tweepy.models.Status.first_parse = tweepy.models.Status.parse
@thedod
thedod / FUD.LOL
Last active December 12, 2015 08:18
ZOMG! I CAN RITE LOLCODE!!1
HAI 1.2 BTW I DOAN KNOE Y I SAY STUPH LIEK 1.2 LOL
I HAS A FUD
I HAS A EMPTY ITZ FAIL
I HAS A STUPH ITZ MAEK EMPTY A NUMBR
I HAS A EATED ITZ "OM NOM NOM U HAZ NO :{FUD} I EATED IT"
IM IN YR KITCHEN NERFIN YR STUPH TIL EMPTY
VISIBLE "WUT DO U HAS?"
GIMMEH FUD
FUD, WTF?
OMG "NOTHING"
@godber
godber / AUTHORS
Last active July 4, 2023 13:21
pdfinfo - A simple python wrapper of the pdfinfo command line tool.
Austin Godber - [email protected]
@ilevantis
ilevantis / Mixcloud RSSifier
Last active August 14, 2024 12:04
Turn mixcloud streams into an RSS feed e.g. for mixcloud.com/<mixcloudstream>/playlists/<streamplaylist-if-there-is-one>/ go to mysite.com/mixcloud-rssifier/?fname=<mixcloudstream>&lname=<streamplaylist-if-there-is-one> to get an RSS feed of the stream or the playlist from the stream
<?php
header('Content-Type: application/rss+xml; charset=UTF-8');
// suck in the query string variables
$feed_name = htmlspecialchars($_GET['fname']);
$list_name = htmlspecialchars($_GET['lname']);
// compose the api urls + other stuff depending on presence of playlist
if(isset($_GET['lname'])) {
$json_url = 'http://api.mixcloud.com/'.$feed_name.'/playlists/'.$list_name.'/cloudcasts/';
@nhimf
nhimf / mqtt-to-influx.py
Created February 4, 2016 21:08
Very crude Python script to transfer data from mqtt to InfluxDB
import paho.mqtt.client as mqtt
from influxdb import InfluxDBClient
import datetime
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
@tzapu
tzapu / AutoConnectWithHTTPServer
Created February 8, 2016 07:25
WiFiManager auto connect and start a http web server
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include "WiFiManager.h" //https://github.com/tzapu/WiFiManager
std::unique_ptr<ESP8266WebServer> server;
void handleRoot() {
@random-robbie
random-robbie / requests.py
Last active October 26, 2021 02:10
Python Requests Ignore Bad SSL certificate
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
URL = "https://www.somesitewithbadssl.com"
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0","Connection":"close","Accept-Language":"en-US,en;q=0.5","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Upgrade-Insecure-Requests":"1"}
response = session.get(URL, headers=headers, timeout=15, verify=False)
result = response.text
print (result)
@Plasmoxy
Plasmoxy / HowToSetupJenkinsCIWithGitLab.md
Last active December 16, 2023 14:44
How to setup Continous Integration for GitLab with Jenkins (works for private projects)

How to setup Continous Integration for GitLab with Jenkins

Hi, I'd like to share with you how I got my Jenkins CI set up for my private GitLab projects. This is more like a sheet of notes of mine, but I hope it'll help someone as I haven't found any good tutorial for Jenkins+Gitlab on the web yet :D

Here we go:

  • generate ssh keys on own server -> PUBLIC and PRIVATE ( no passphrase )
  • go to GitLab profile settings -> SSH keys -> add PUBLIC ssh key to GitLab = this will allow your Jenkins server to access your GitLab
  • also create full access GitLab API access token for Jenkins on your gitlab profile settings and keep it

  • install Git + GitLab plugin on Jenkins ( make sure they are enabled (ticked) in Jenkins !!!)
@kalebo
kalebo / subprocess_tee.py
Last active March 13, 2024 20:53
Emulate tee with python's async subprocess (>= 3.6)
class RunOutput():
def __init__(self, returncode, stdout, stderr):
self.returncode = returncode
self.stdout = stdout
self.stderr = stderr
# the following three commands are adapted from https://kevinmccarthy.org/2016/07/25/streaming-subprocess-stdin-and-stdout-with-asyncio-in-python/
async def _read_stream(stream, callback):
while True:
line = await stream.readline()
#!/bin/sh
SCOPES='read write follow'
if [ "$#" = "1" ]; then
RESPONSE_APP=$(curl -XPOST -F 'client_name=DoYouSuckDicks' -F "redirect_uris=urn:ietf:wg:oauth:2.0:oob" -F "scopes=$SCOPES" -F 'website=https://example.org' https://$1/api/v1/apps)
CLIENT_ID=$(echo $RESPONSE_APP | jq -r .client_id)
CLIENT_SECRET=$(echo $RESPONSE_APP | jq -r .client_secret)