Skip to content

Instantly share code, notes, and snippets.

View Aeon's full-sized avatar
🦴

Anton Stroganov Aeon

🦴
View GitHub Profile
@Aeon
Aeon / gist:2054750
Created March 17, 2012 03:39
psql drop function definitions
SELECT 'DROP FUNCTION ' || quote_ident(ns.nspname) || '.' || quote_ident(proname) || '(' || oidvectortypes(proargtypes) || ');'
FROM pg_proc INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid)
WHERE ns.nspname = 'my_messed_up_schema' order by proname;
@Aeon
Aeon / bla.js
Created November 30, 2012 01:29
js refactoring...
var should_reset = false;
if (condition1) {
alert(1);
}else if (condition2) {
alert(2);
should_reset = true;
}else if (condition3) {
alert(3);
should_reset = true;
@Aeon
Aeon / pick_banner.js
Last active December 11, 2015 22:08 — forked from istro/foobar
ads = [
{width: 1000, height:500},
{width: 200, height:200},
{width: 600, height:750},
{width: 600, height:600}
];
screen_ratio = window.document.width / window.document.height;
minimum_area = window.document.width * window.document.height * 0.8;
@Aeon
Aeon / httpd-vhost.conf
Created February 12, 2013 22:31
sample httpd-vhost.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
NameVirtualHost *:81
<VirtualHost *:81>
# optional
@Aeon
Aeon / blabla.md
Last active December 14, 2015 07:59
forking and db resources and postgres

anyway what happens is

  • parent opens db connection $db
  • parent forks child worker, which inherits the connection resource
  • child worker does some work and exits (successfully or not)
  • php cleans up any open resource handles, $db among them.
  • parent thinks $db is still a valid resource.
  • parent tries to access it, or parent forks a new child and gives it the invalid handle...
  • php goes boom, because it tries to use an invalid connection resource.
@Aeon
Aeon / gist:5110246
Last active December 14, 2015 15:48
moving files - there and back again
if you have a list of files that you had to temporarily move
out of a nested subdirectory set into a single directory, you
can move them back correctly by doing this on the list of
original locations
search and replace
^(.*?)?([^/\n]*/?)$
with
mv "$2" "/origin/$0"
git log --author="`git config user.name`" --shortstat --since=yesterday | egrep 'files? changed' | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "", files, "files changed,", inserted, "insertions(+),", deleted, "deletions(-)"}'
@Aeon
Aeon / adapters-application.js
Last active March 21, 2016 18:50
faye adapter for ember-data
require('config/adapters/faye-adapter');
export default DS.FayeAdapter.extend();
@Aeon
Aeon / mtool.rb
Last active August 29, 2015 13:57
require 'api/pools.rb'
module Mtool
extend Blather::DSL
#Blather.logger.level = Logger::DEBUG
Blather.logger.level = Logger::INFO
@@faye = nil
#!/usr/bin/env ruby
require 'resque'
Resque.redis.namespace = "resque:#{ENV['APP_NAME']}"
while Resque::Failure.count > 0 do |i|
job = Resque::Failure.all(0,1)
unless !job || job['retried_at'].nil?
Resque::Failure.remove(0)
else
break