Skip to content

Instantly share code, notes, and snippets.

View fordnox's full-sized avatar
🍕
Eating pizza

Andrius Putna fordnox

🍕
Eating pizza
View GitHub Profile
@fordnox
fordnox / proxy.py
Created March 21, 2014 08:04
python proxy
#!/usr/bin/python
import json
from subprocess import Popen, PIPE
txt = raw_input();
cmd = txt.split()
o = None
e =None
try:
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
@fordnox
fordnox / 1fh.vcl
Last active August 29, 2015 13:59
Most simple varnish VCL /etc/varnish/1fh.vcl
backend default {
.host = "127.0.0.1"; # IP address of your backend (Apache, nginx, etc.)
.port = "8080"; # Port your backend is listening on
}
sub vcl_recv {
# Set the URI of your system directory
if (req.request == "POST" || req.http.X-Requested-With == "XMLHttpRequest")
{
@fordnox
fordnox / bootstrap.php
Created May 17, 2014 09:52
PHP snippet to throw exceptions instead of fatal errors
<?php
register_shutdown_function(function() {
$error = error_get_last();
$message = $error['message'];
if ($error['type'] == 64 && !empty($message)) {
throw new Exception($message);
}
});
@fordnox
fordnox / fb.js
Created June 29, 2014 11:09
One time popup jQuery with facebook like page
$(document).ready(function() {
function rC(nam) {var tC = document.cookie.split('; '); for (var i = tC.length - 1; i >= 0; i--) {var x = tC[i].split('='); if (nam == x[0]) return unescape(x[1]);} return '~';}
function wC(nam,val) {document.cookie = nam + '=' + escape(val);}
function lC(nam,pg) {var val = rC(nam); if (val.indexOf('~'+pg+'~') != -1) return false; val += pg + '~'; wC(nam,val); return true;}
function firstTime(cN) {return lC('meskuciobatonelis',cN);}
function thisPage() {var page = location.href.substring(location.href.lastIndexOf('\/')+1); pos = page.indexOf('.');if (pos > -1) {page = page.substr(0,pos);} return page;}
if (firstTime(thisPage())) {
$('<div>')
Verifying that +putna is my Bitcoin username. You can send me #bitcoin here: https://onename.io/putna
@fordnox
fordnox / fb_friends.py
Created February 25, 2015 20:46
Facebook friends pictures
import requests
import json
import urllib2
import webbrowser
from pprint import pprint
token = ''
api_url = 'https://graph.facebook.com/v2.1/'
params = {'access_token' : token}
@fordnox
fordnox / latest.html
Created February 27, 2015 09:08
Lastes version of software from github
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container">
<p>
<a href="#" class="release-download btnd btnd-1 btnd-1d">Download</a>
@fordnox
fordnox / RabbitRpc.php
Created June 9, 2015 13:05
RabbitRpc.php
<?php
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
class RabbitRpc
{
const TIMEOUT = 15;
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@fordnox
fordnox / Facebook.php
Created July 29, 2011 08:25
Very simple Facebook graph executor
<?php
namespace Ai;
class Facebook
{
private $token;
public function __construct($token)
{
$this->token = $token;