Skip to content

Instantly share code, notes, and snippets.

@AlexanderPavlenko
AlexanderPavlenko / gist:1291017
Last active September 27, 2015 15:27
android 2.3, fix "device not provisioned"
$ adb shell
$ cd data/data/com.android.providers.settings/databases
$ sqlite3 settings.db
sqlite> .tables
sqlite> select * from secure;
sqlite> INSERT INTO secure (name, value) VALUES ('device_provisioned', 1);
sqlite> .exit
@AlexanderPavlenko
AlexanderPavlenko / ypdns.php
Created February 5, 2012 11:40
YPDNS IP updater
#!/usr/bin/php5
<?php
class AUpdater {
private $cookies;
private $credentials = array(
'username' => '...',
'password' => '...',
'mysubmit' => 'Sign+In'
);
@AlexanderPavlenko
AlexanderPavlenko / CONFIG_FILE
Created February 5, 2012 11:48
Monitoring IP changes
### IPdetect configuration file
### (c) Mariusz Kaczmarczyk, 2005+
### Content of this file is subject to GPL version 2 license
### (http://www.gnu.org/licenses/gpl.html).
### This is shell include file, use rules for shell script files.
### Values should be VARIABLE='value' (no spaces around equal sign!).
### See 'man 1 bash' for details on how to write shell scripts.
# Force PATH to this value. For security reasons, do not change unless you
@AlexanderPavlenko
AlexanderPavlenko / SkypeAntiSpam.pyw
Created February 5, 2012 12:09
anti-spam for Skype
import Skype4Py
from time import sleep
skype = Skype4Py.Skype()
TRYING = 1
TEXT = {
'QUESTION':"Hello. It's antispam bot. Answer, 2+2=? One figure, please. You have %i trying." % (TRYING),
'ANSWER':"4",
'WIN':"Right. I'll write you soon.",
'AGAIN':"Try one more time.",
'FAIL':"Autoignoring.",
@AlexanderPavlenko
AlexanderPavlenko / set_7_usb_boot.cmd
Created April 1, 2012 20:22
usbbootfix.bat doesn't help by itself since SP1, but may be involved, so run it before set_7_usb_boot.cmd
@echo off
setlocal EnableExtensions EnableDelayedExpansion
pushd %~dp0
rem set_7_usb_boot.cmd v0.02
rem created by cdob
echo prepare offline windows 7 registry, set USB boot drivers &echo.
set System_Root=\Windows
if not %1.==. set System_Root=%1
@AlexanderPavlenko
AlexanderPavlenko / wrap_erb.rb
Created May 8, 2012 17:16
wrap erb template into erb template
#!/usr/bin/env ruby
filename = ARGV[0]
str = File.read filename
blocks = str.split('<%').map{|s| s.empty? ? s : s.split('%>') }.flatten
inside = false
blocks.map do |block|
if inside
block.gsub! '\\', '\\\\\\\\'
block.gsub! '"', '\"'
block.gsub! '#{', '#" %><%= "{" + "'
class Base64ImageWrapper < StringIO
def initialize(data, name=nil)
@name = name || 'image'
@blob = Base64.decode64(data)
super @blob
end
def original_filename
"#@name.#{content_type.split('/').last}"
@AlexanderPavlenko
AlexanderPavlenko / fix.rb
Last active December 12, 2015 03:28
fix PostgreSQL comparison of string and number
module Arel::Visitors
class ToSql
alias :visit_Fixnum :quoted
alias :visit_Bignum :quoted
end
end
module ActiveRecord::ConnectionAdapters
class PostgreSQLAdapter
module FixNumberToStringComparison
f = File.open('/tmp/tr', 'w')
set_trace_func proc {
|event, file, line, id, binding, classname|
if event == "call" or event == "return"
f.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
end
}
require 'timeout'
Timeout.timeout(0.5) do
begin
sleep 1
rescue Exception => ex
puts ex.inspect
puts 'ಠ_ಠ'
end
end