Skip to content

Instantly share code, notes, and snippets.

View alexanderk23's full-sized avatar

Alexander Kovalenko alexanderk23

View GitHub Profile
@alexanderk23
alexanderk23 / gist:5209578
Last active December 15, 2015 05:29
Pure JS solution
<html>
<head>
<script src="https://raw.github.com/remy/twitterlib/master/twitterlib.min.js"></script>
<script src="https://raw.github.com/timrwood/moment/2.0.0/min/moment.min.js"></script>
</head>
<body>
<div id="tweet" data-username="bountify"></div>
<script>
var tweet = document.getElementById('tweet');
var username = tweet.getAttribute('data-username');
"""Generic linux daemon base class for python 3.x.
Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/"""
import sys, os, time, atexit, signal, errno
class daemon:
"""A generic daemon class.
Usage: subclass the daemon class and override the run() method."""
namespace :symfony do
namespace :assets do
desc "Updates assets version"
task :update_version do
run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/app/config/config.yml"
end
end
end
before "symfony:assetic:dump" do
@alexanderk23
alexanderk23 / tree.md
Created November 10, 2013 19:20 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@alexanderk23
alexanderk23 / deep_open_struct.rb
Created December 4, 2013 12:56
DeepOpenStruct with recursive to_h
class DeepOpenStruct < OpenStruct
def to_h
convert_to_hash_recursive self.dup
end
def self.load item
raise ArgumentError, "DeepOpenStruct must be passed a Hash or Array" unless(item.is_a?(Hash) || item.is_a?(Array))
self.convert_from_hash_recursive item
end
@alexanderk23
alexanderk23 / Makefile
Last active December 31, 2015 04:09
Makefile
UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
OSFLAGS=-D_OSX
endif
ifeq ($(UNAME),Linux)
OSFLAGS=-D_LINUX
endif
CC=gcc
CFLAGS=-std=gnu99 -lm -s -x c -O2 -Wall -Wno-unused -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE $(OSFLAGS)
SOURCES=my_strategy.c runner.c remote_process_client.c model/world.c platform/net.c
@alexanderk23
alexanderk23 / fucking-great-indicator.py
Last active January 3, 2016 02:39
Fucking Great Indicator
#!/usr/bin/env python
# coding: utf-8
APPNAME = u"Охуенный блять совет"
URI = 'http://fucking-great-advice.ru/'
API_URI = URI + 'api/random'
SOUND_URI = URI + 'files/sounds'
INTERVAL = 350
from gi.repository import AppIndicator3 as AI
###
# Read in XML as a stream, write out JSON as a stream. As little information
# is kept in memory as possible.
require 'nokogiri'
require 'psych'
class JSONTranslator < Nokogiri::XML::SAX::Document
attr_reader :emitter
def initialize emitter
[Desktop Entry]
Version=9
Name=Teamviewer 9
Comment=
Exec=/home/user/.teamviewer9/teamviewer
Icon=/home/user/.teamviewer9/tv_bin/desktop/teamviewer.png
Terminal=false
Type=Application
Categories=Utility;Application;
@alexanderk23
alexanderk23 / scrview.py
Last active January 12, 2023 15:18
scrview.py: ZX Spectrum SCREEN$ viewer & trdtool.py: TRD disk image tool
#!/usr/bin/env python
"""scrview.py: ZX Spectrum SCREEN$ viewer"""
import sys
import Image
from array import array
class ZXScreen:
WIDTH = 256