Skip to content

Instantly share code, notes, and snippets.

<?php
abstract class stdConst
{
private $c;
public function __construct($c)
{
// requirement is for a class to be named <Something>Const
// so static methods can be called on <Something>
@grakic
grakic / einicijativa2011.txt
Created June 4, 2011 15:40
Narodna inicijativa - kraća izmena
Radna varijanta predloga izmena Nacrta zakona o referendumu i narodnoj inicijativi.
Nove ideje stižu u prepisci e-poštom, a aktivna je i #einicijativa na Tviteru.
Javna rasprava traje do 18. juna: http://www.drzavnauprava.gov.rs/news/?id=2394
Tekst Nacrta je dostupan na: http://bit.ly/lSwcFc
Cilj sledećih predloženih izmena je uvođenje ravnopravnosti elektronskog dokumenta
i elektronskog potpisa u skladu sa postojećim propisima.
@grakic
grakic / load_maze_map.js
Created June 1, 2012 03:26
Blockly Maze
/**
* Go to http://blockly-demo.appspot.com/blockly/demos/maze/index.html
* and paste this function into your browser's javascript inspector
*
* Setup new Maze MAP: 1 for empty, 0 for path, 2/3 for start/finish
* Maze.MAP = [
* [1, 1, 1, 1, 1, 1, 1, 1],
* [1, 0, 1, 1, 3, 1, 0, 1],
* [1, 0, 1, 1, 0, 0, 0, 1],
* [1, 0, 1, 1, 0, 1, 1, 1],
@grakic
grakic / mysqli.php
Last active December 12, 2015 12:38
A small mysqli wrapper to prevent SQLi
<?php
class mysqli extends \mysqli {
// ...
public function safe_query($query)
{
$args = array_slice(func_get_args(), 1);
$safe_sql = $this->format_query($query, $args);
@grakic
grakic / nbody.py
Last active August 29, 2015 14:07
from math import pi, sqrt
solar_mass = 4 * pi * pi
days_per_year = 365.24
class Body:
def __init__(self, x, y, z, vx, vy, vz, mass):
self.x = x
self.y = y
self.z = z

Keybase proof

I hereby claim:

  • I am grakic on github.
  • I am grakic (https://keybase.io/grakic) on keybase.
  • I have a public key whose fingerprint is E3D8 8D5F B37A 7B38 E8F2 3863 C6F2 C841 78D8 99AF

To claim this, I am signing this object:

@grakic
grakic / wp_require_login.php
Last active August 29, 2015 14:16
Simple WordPress plugin to require login for site access, showing welcome content on frontpage for non-authenticated users. Uses personalized links to authorize access to feeds.
<?php
/*
Plugin Name: Require Login
Plugin URI:
Author: Goran Rakic
Version: 2.0
Author URI: http://blog.goranrakic.com
*/
/**
@grakic
grakic / cookiejar.php
Created June 16, 2015 09:09
Cookiejar to $_COOKIE and back
function save_to_cookiejar($cookiefile)
{
$jar = "";
foreach ($_COOKIE as $name => $value)
{
$name = urlencode($name);
$value = urlencode($value);
$jar .= "{$_SERVER['HTTP_HOST']}\tFALSE\t/\tFALSE\t0\t{$name}\t{$value}\n";
}
file_put_contents($cookiefile, $jar);
@grakic
grakic / functions.php
Last active January 24, 2016 18:15
Load custom WP Jetpack translations
<?php
define('CHILD_DIR', get_stylesheet_directory());
/**
* Load Jetpack translations from themes/<theme>/lang/jetpack-sr_RS.mo
*/
function my_theme_setup()
{
unload_textdomain('jetpack');
from sqlalchemy_continuum.plugins import Plugin
from sqlalchemy_continuum import Operation
from sqlalchemy.inspection import inspect
class RelatedVersioningPlugin(Plugin):
def __init__(self):
self.class_registry = []