Skip to content

Instantly share code, notes, and snippets.

View zodman's full-sized avatar
🤗
Code wins arguments!

Andres Vargas zodman

🤗
Code wins arguments!
View GitHub Profile
@renyi
renyi / gist:7019854
Created October 17, 2013 06:16
Django, download and store image in ImageField
image_url = og.get('image')
if image_url:
import urllib2
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
img_temp = NamedTemporaryFile(delete=False)
img_temp.write(urllib2.urlopen(image_url).read())
img_temp.flush()
import os
@sdoro
sdoro / gist:4291961
Created December 15, 2012 07:39
restart OpenVPN server in CLI pfsense
echo "<?php include('openvpn.inc'); openvpn_resync_all();?>" | php -q
@codeinthehole
codeinthehole / uwsgi_stats
Last active May 15, 2019 22:00
Zabbix plugin script for extracting uWSGI metrics from a log file
#!/usr/bin/env python
"""
Extract metrics from a uWSGI log file
This should be saved as /etc/zabbix/pluginx/uwsgi_stats and called from
/etc/zabbix/zabbix_agentd.conf.d/uwsgi.conf, which should have contents:
UserParameter=uwsgi.stats[*],/etc/zabbix/plugins/uwsgi_stats $1 $2
To gather these metrics in Zabbix, create a new item which calls this plugin and
@NicolasLoew
NicolasLoew / index.php
Created June 24, 2017 06:26 — forked from null-dev/index.php
1fichier.com direct link generator (PHP)
<?php
if(!isset($_GET['a'])) {
die('<form action="" method="get"><input type="text" name="a"/><input type="submit"/></form>');
}
$url = "https://1fichier.com/?" . urlencode($_GET['a']) . "?auth=1&inline";
stream_context_set_default(array(
'http' => array(
'method' => 'GET',
'header' => 'Authorization: Basic ' . '[BASE64 encoded login credentials. Format: "user:pass" (without quotes)]'
@aleksihakli
aleksihakli / models.py
Last active August 20, 2021 16:07
Django single session
from django.conf import settings
from django.contrib.sessions.models import Session
from django.db import models
class UserSession(models.Model):
"""
UserSession
Session tracking and management inspired by Gavin Ballard:
@maple3142
maple3142 / show_git_branch.lua
Last active September 26, 2021 14:14
clink show git branch
function show_git_branch()
for line in io.popen("git branch 2>nul"):lines() do
local m = line:match("%* (.+)$")
local b = "\x1b[32;22;49m".."("..m..")".."\x1b[39;22;49m"
if m then
clink.prompt.value = clink.prompt.value:gsub(">"," "..b.." >")
break
end
end
return false
@sreeragh-ar
sreeragh-ar / python_quick_tips.ipynb
Created June 23, 2021 14:07
Python_quick_tips.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@reidransom
reidransom / gist:6167543
Last active December 8, 2022 05:50
HandBrakeCLI encoding for HTML5 Video

HandBrakeCLI --input 88Min_20_v2.mov --output 88Min_20_v2-handbrake.mp4 --large-file --optimize --encoder x264 --x264-preset medium --x264-profile high --x264-tune zerolatency --encopts level=3.1:vbv-bufsize=17500:vbv-maxrate=17500 --quality 22 --width 960 --height 540 --pixel-aspect 1:1 --decomb

@antonbabenko
antonbabenko / curl_all.sh
Created January 12, 2012 14:44
Curl list of urls and save http response code & times (useful for cache warmup)
#!/bin/bash
while read LINE; do
curl -o /dev/null --silent --progress-bar --head --write-out '%{http_code} %{time_starttransfer} %{url_effective}\n' "$LINE" >> urls_result.txt
done < urls.txt