Skip to content

Instantly share code, notes, and snippets.

View kalmanolah's full-sized avatar

Kalman Olah kalmanolah

View GitHub Profile
@kalmanolah
kalmanolah / linkifyTweet.js
Last active December 14, 2015 08:19
A simple Javascript function that linkifies a tweet object's text based on that tweet's entities.
/**
* A simple Javascript function that linkifies a tweet object's text based on that tweet's entities.
*
* More info about Tweet Entities: https://dev.twitter.com/docs/tweet-entities .
*
* NOTE: You may need to add "include_entities=1" or "include_entities=true" to your API request.
*/
function linkifyTweet(tweet){
if(!tweet.entities){
return tweet.text;
@kalmanolah
kalmanolah / KickAssTorrents_LinkFixer.user.js
Last active April 16, 2016 16:27
This userscript for Greasemonkey disables those pesky confirmation dialogs/pages that links in KAT torrent description blocks show when clicked. It should help reduce my stress levels quite a bit.
// ==UserScript==
// @name KickAssTorrents LinkFixer
// @namespace KATLinkFixer
// @description Disables the confirmation dialogs/pages that links in the description block of KAT torrents show when clicked.
// @include /^(http|https)://kat\.ph/[a-zA-Z0-9-]+\.html$/
// @version 1.0.3
// @grant none
// @updateURL https://gist.github.com/kalmanolah/5067676/raw/KickAssTorrents_LinkFixer.user.js
// ==/UserScript==
(function(){
@kalmanolah
kalmanolah / cloudtobutt.user.js
Last active March 4, 2021 07:58
Replaces instances of "(The) Cloud" with "(My) Butt". Ported from and Inspired by panicsteve's cloud-to-butt extension for Google Chrome, and DaveRandom's ports thereof.
// ==UserScript==
// @name Cloud to Butt
// @namespace cloudtobutt
// @description Replaces instances of "(The) Cloud" with "(My) Butt". Ported from and Inspired by panicsteve's cloud-to-butt extension for Google Chrome, and DaveRandom's ports thereof.
// @include *
// @version 1.0.1
// @grant none
// @updateURL https://gist.github.com/kalmanolah/5764435/raw/cloudtobutt.user.js
// ==/UserScript==
(function() {
@kalmanolah
kalmanolah / TranslationsMergeCommand.php
Created June 27, 2013 11:27
Symfony2 console command for merging translation files from multiple bundles and copying the merged files over to the app/Resources/translations directory, all the while preserving any existing key/value pairs of any existing translation files in the app/Resources/translations directory. This is effectively safe(r) versioning.
<?php
namespace KalmanOlah\ExampleBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Dumper;
@kalmanolah
kalmanolah / GistService.php
Last active December 20, 2015 13:39
A Symfony2 service for fetching all of a Github user's gists. Gist content for the 10 latest gists is downloaded, and Github API responses are cached using APC.
<?php
/**
* A Symfony2 service for fetching all of a Github user's gists.
* Gist content for the 10 latest gists is downloaded, and Github API responses are cached using APC.
* The APC extension for PHP needs to be enabled.
*
* In order to use this Service, you should add the following services to Symfony2:
*
* services:
* cache:
@kalmanolah
kalmanolah / haste.py
Last active December 8, 2021 21:47
Simple python script for putting things on hastebin. The resulting hastebin URL is copied to your primary clipboard using xsel. Usage: `cat yourfile.txt | haste`, `haste yourfile.txt`, 'haste` or `haste --clip`. `haste --help` for help.
#!/usr/bin/env python3
# @python3
# @author Kalman Olah <hello@kalmanolah.net>
"""A hastebin CLI tool."""
import click
import json
import requests
import subprocess
import sys
@kalmanolah
kalmanolah / GravatarExtension.php
Created August 21, 2013 12:35
Symfony2 Twig extension for generating gravatar links for stuff. Accepts objects with a `getEmail()` function, arrays with an `email` key, or just a string.
<?php
/**
* This goes in your services.yml:
*
* services:
* example.twig.gravatar_extension:
* class: My\ExampleBundle\Twig\GravatarExtension
* tags:
* - { name: twig.extension }
*/
@kalmanolah
kalmanolah / postalcodes.belgium.json
Last active December 21, 2015 22:49
JSON object mapping postal codes from Belgium to city names. I found the postal codes on `http://www.charline.be/info/codepost/cpost.htm`.
{"9420":"Aaigem","8511":"Aalbeke","9300":"Aalst","3800":"Aalst (Limb.)","9880":"Aalter","3200":"Aarschot","8700":"Aarsele","8211":"Aartrijke","2630":"Aartselaar","4557":"Abée","4280":"Abolens","3930":"Achel","5590":"Achêne","5362":"Achet","4219":"Acosse","6280":"Acoz","9991":"Adegem","8660":"Adinkerke","1790":"Affligem","9051":"Afsnee","5544":"Agimont","4317":"Aineffe","5310":"Aische-en-Refail","6250":"Aiseau","6250":"Aiseau-Presles","5070":"Aisemont","3570":"Alken","5550":"Alle","4432":"Alleur","1652":"Alsemberg","8690":"Alveringem","4540":"Amay","6680":"Amberloup","4770":"Amblève","6953":"Ambly","4219":"Ambresin","4770":"Amel","6997":"Amonines","7750":"Amougies","4540":"Ampsin","5300":"Andenne","1070":"Anderlecht","6150":"Anderlues","4821":"Andrimont","4031":"Angleur","7387":"Angre","7387":"Angreau","5537":"Anhée","6721":"Anlier","6890":"Anloy","5537":"Annevoie-Rouillon","4430":"Ans","5500":"Anseremme","7750":"Anseroeul","5520":"Anthée","4520":"Antheit","4160":"Anthisnes","7640":"Antoing","2000":"Antwerpen
@kalmanolah
kalmanolah / kalmanolah_redmine_improvements.user.js
Last active December 23, 2015 10:19
Userscript for making small improvements to Redmine.
// ==UserScript==
// @name Redmine Improvements
// @namespace kalmanolah_redmine_improvements
// @description Improvements for Redmine.
// @include https://your.redmine.instance/*
// @version 1.0.0
// @grant none
// @updateUrl https://gist.github.com/kalmanolah/6621123/raw/kalmanolah_redmine_improvements.user.js
// @run-at document-end
// ==/UserScript==
@kalmanolah
kalmanolah / Variable.php
Last active January 29, 2019 20:18
A Symfony2 Service & Doctrine entity combo for persisting variables and configuration to the database. Inspired heavily by Drupal's variable_get() and variable_set() functions, which can be found here: https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/variable_set/7 .
<?php
namespace Your\ExampleBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @UniqueEntity("name")
*/