Skip to content

Instantly share code, notes, and snippets.

View farazdagi's full-sized avatar

Victor Farazdagi farazdagi

View GitHub Profile
@farazdagi
farazdagi / jsonp-in-flask.py
Created July 18, 2011 15:54
JSONP in Flask
import json
from functools import wraps
from flask import redirect, request, current_app
def support_jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
package initialsync
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"time"
"github.com/libp2p/go-libp2p-core/peer"
#! /bin/bash
USER=$1
PASS=$2
usermod --password $(echo $PASS | openssl passwd -1 -stdin) $USER
@farazdagi
farazdagi / clickjack.js
Created February 14, 2018 06:10
External JS code for ClickJacking project (CS6262)
alert("clickjack");
0xadaf150b905cf5e6a778e553e15a139b6618bbb7
// jail.Send() expects to find the current message id in `status.message_id`
// (if not found message id will not be injected, and operation will proceed)
var status = {
message_id: '42' // global message id, gets replaced in sendTransaction (or any other method)
};
var _status_catalog = {
commands: {},
responses: {}
};
@farazdagi
farazdagi / esenio-widget-sample.html
Created December 19, 2015 08:15
How to include Esenio widget on your own web-site.
<script>
(function(window, undefined) {
window.esenio = window.esenio || {};
window.esenio.url = 'https://events.esen.io';
window.esenio.eventSlug = 'demo';
window.esenio.widgetWidth = '100%';
window.esenio.widgetHeight = undefined;
document.writeln('<script src="' + window.esenio.url + '/scripts/widget.js"><\/script>');
}(window));
</script>
@farazdagi
farazdagi / list_crons.sh
Created August 17, 2011 11:49
List cron jobs for all users
#!/bin/bash
# see http://stackoverflow.com/questions/134906/how-do-i-list-all-cron-jobs-for-all-users/137173#137173
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
@farazdagi
farazdagi / gist:1073753
Created July 9, 2011 17:02
paginator compatible with pymongo and mongoengine
# pagination.py
class Paginator(object):
def __init__(self, query, per_page):
"""Initialize a paginator.
Arguments:
- query -- queryset from pymongo or mongoengine
- per_page -- number of items per page