Skip to content

Instantly share code, notes, and snippets.

@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);
<?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 / 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');
@grakic
grakic / DigSigCerts.reg
Created September 23, 2017 18:08
MUP CA sertifikati
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SystemCertificates\ROOT\Certificates\4FA8D4904A9CCC0B8D43695314EE3E7FB5A472F2]
"Blob"=hex:04,00,00,00,01,00,00,00,10,00,00,00,0f,b9,7c,a2,7c,0d,a8,d0,9e,51,\
71,79,cd,73,95,7b,0f,00,00,00,01,00,00,00,14,00,00,00,44,e5,3d,56,25,16,12,\
55,f5,56,4b,6f,bb,b0,79,f1,3d,48,64,d9,14,00,00,00,01,00,00,00,14,00,00,00,\
3f,66,b0,0f,66,fb,f0,10,2e,61,a4,6f,ef,2c,95,8a,14,72,6f,71,19,00,00,00,01,\
00,00,00,10,00,00,00,3c,50,45,8d,84,e7,ce,3f,b2,0c,66,49,42,a1,35,96,03,00,\
00,00,01,00,00,00,14,00,00,00,4f,a8,d4,90,4a,9c,cc,0b,8d,43,69,53,14,ee,3e,\
7f,b5,a4,72,f2,5c,00,00,00,01,00,00,00,04,00,00,00,00,10,00,00,20,00,00,00,\