Skip to content

Instantly share code, notes, and snippets.

View allixsenos's full-sized avatar

Luka Kladarić allixsenos

View GitHub Profile
@allixsenos
allixsenos / xdebugexception.php
Created September 29, 2011 21:18
xdebug exception fatal
<?php
ini_set("display_errors", 1);
ini_set("error_reporting", E_ALL);
echo "<pre>";
class MyException extends Exception {
function __construct($message) {
parent::__construct($message);
$this->line = "42"; // this triggers it. if it's before the constructor, PHP freaks out regardless of xdebug
@allixsenos
allixsenos / gist:1277242
Created October 11, 2011 04:04
tumblr js injection
javascript:d=document;s=d.createElement('style');s.type='text/css';s.innerHTML=".post{-webkit-transition: all 5s ease-in-out; -moz-transition: all 5s ease-in-out; -o-transition: all 5s ease-in-out;}.post:hover{-webkit-transform: rotate(1800deg) scale(1); -moz-transform: rotate(1800deg) scale(1); -o-transform: rotate(1800deg) scale(1);}";d.getElementsByTagName('head')[0].appendChild(s);
@allixsenos
allixsenos / gist:1281641
Created October 12, 2011 16:01
share on Google+ bookmarklet
javascript:var%20f='https://plusone.google.com/_/+1/confirm?url=',l=document.location,p=encodeURIComponent(l.href);a=function(){if(!window.open(f+p,'sharer','toolbar=0,status=0,resizable=1,width=470,height=330'))l.href=f+p;};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0);}else{a();}void(0);
@allixsenos
allixsenos / gist:2892164
Created June 7, 2012 22:46 — forked from JosephLenton/gist:2891648
pretty errors
<?
/**
* Pretty Errors
*
* ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
*
* WARNING! It is downright _DANGEROUS_ to use this in production, on
* a live website. It should *ONLY* be used for development.
*
* Pretty Errors allows the outside world to alter your project,
@allixsenos
allixsenos / duznici.php
Created July 31, 2012 13:32
parser za popis duznika - php 5.4
#!/usr/local/php5/bin/php
<?php
$files = glob('*/svi/*.html');
$fields = [];
$fields['po'] = [
'rbr',
'imeprezime',
'mjesto',
@allixsenos
allixsenos / explain.py
Last active June 2, 2019 10:08
Django QuerySet Explain
from django.db import connections
from django.db.models.query import QuerySet
from __future__ import print_function
class QuerySetExplainMixin:
def explain(self, analyze=True):
cursor = connections[self.db].cursor()
print(self.query)
print()
sql, params = self.query.sql_with_params()

Keybase proof

I hereby claim:

  • I am allixsenos on github.
  • I am allixsenos (https://keybase.io/allixsenos) on keybase.
  • I have a public key whose fingerprint is 2A2F 3C2A B502 941C B0F8 7E9B 6561 D338 82BC FA74

To claim this, I am signing this object:

'''
Django bulk upsert
Does not attempt to cover all corner cases and related models.
Originally from http://people.iola.dk/olau/python/bulkops.py
Heavily modified by Luka Kladaric hello@luka.io
'''
from itertools import repeat
from django.db import models, connections, transaction
@allixsenos
allixsenos / phabricator-map-accounts-to-LDAP.sql
Last active March 11, 2018 13:15
This query will create LDAP mappings for all accounts that don't have them. Useful for migrating from Phacility to self-hosted using LDAP as the only auth method.
USE phabricator_user;
-- create LDAP mappings for unmapped users
-- this query uses a subselect due to the way MySQL reacts to UUID() being
-- wrapped in REPLACE() (returns the same UUID for all rows)
-- WARNING: make sure user.userName maps to LDAP usernames, otherwise
-- user_externalaccount.accountID needs to be modified for those users
-- where it doesn't. alternatively, use Phabricator's change username
-- utility in People app to change those users' usernames before running
INSERT INTO user_externalaccount

Simple Security Guidelines

  • Use an iDevice

    • Use an iPod or an iPad without a SIM card
    • Use an iPhone
    • Do not jailbreak
    • Always upgrade to new iOS versions
  • Use Signal (iOS + Android)