Skip to content

Instantly share code, notes, and snippets.

View andy722's full-sized avatar

Andy Belsky andy722

  • as a private person here
  • Russia, Novosibirsk
View GitHub Profile
/**
* Static utility methods for bicycle data-serial mapping.
*
* <p>The PHP code part developer is a motherfucker.
* Rationale for this class is to repair at least some of the damage caused by the fact.</p>
*/
public class BDSM {
....
/**
* Static utility methods for bicycle data-serial mapping.
*
* <p>The PHP code part developer is a motherfucker.
* Rationale for this class is to repair at least some of the damage caused by the fact.</p>
*/
public class BDSM {
....
@andy722
andy722 / SerializationUtils.java
Created December 27, 2011 19:59
(de)serialization into Base64-encoded string for future persisting
package com.abelsky.scrumtimer.util;
import android.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@andy722
andy722 / gist:1716190
Created February 1, 2012 09:44
MySQL: detecting UNIQUE constraint violation
SQLException e;
...
if (e.getErrorCode() == MysqlErrorNumbers.ER_DUP_ENTRY) {
// UNIQUE constraint violation
}
@andy722
andy722 / block-java.bat
Created April 16, 2012 11:21
Disables/enables incoming network connections for Java launcher using Windows Firewall.
@echo off
::
:: Disables/enables incoming network connections for Java launcher
:: using Windows Firewall. Requires administrative rights.
::
:: Edit JDK_PATH variable below to specify JDK/JRE installation to be blocked.
::
set JDK_PATH=C:\Program Files\Java\jdk1.6.0_30
@andy722
andy722 / gist:2867375
Created June 4, 2012 09:09
Workaround for ConfigParser to read .properties-style configs (ones with no section headers)
import string
import ConfigParser
class FakeSectionHeader(object):
'''Workaround for config parser to read .properties-style configs'''
def __init__(self, fp):
self.fp = fp
self.sechead = '[' + ConfigParser.DEFAULTSECT + ']\n'
@andy722
andy722 / svn-rev-search.sh
Created June 21, 2012 12:18
Searches for a pattern in all SVN changes to a specified file or directory
#!/bin/bash
#
# Searches for a pattern in all SVN changes to a specified file or directory.
#
# Usage:
# ./svn-rev-search.sh <file-name> <pattern>
#
file="$1"
pattern="$2"
@andy722
andy722 / deploy.bat
Created July 9, 2012 09:52
Windows batch: iterate over a static array - copies specified files
@echo off
set SRC=C:\some-path
set TARGET=\\REMOTE-HOST\other-path
set FILE_LIST=(file1.py file2.py file3.py file4.py)
for %%i in %FILE_LIST% do copy /Y %SRC%\%%i %TARGET%
@andy722
andy722 / gist:3716773
Created September 13, 2012 19:02
Python enumeration
def enum(*sequential, **named):
"""Creates an enumeration.
Usage:
>>> Numbers = enum('ZERO', 'ONE', 'TWO')
>>> Numbers.ZERO
0
"""
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
<link rel="alternate" type="application/rss+xml" href="http://url-of-an-rss-feed">