Skip to content

Instantly share code, notes, and snippets.

View revmischa's full-sized avatar
🇺🇦

Mischa Spiegelmock revmischa

🇺🇦
View GitHub Profile
@revmischa
revmischa / gist:0ac56ddd2026ca1d05ee
Last active August 29, 2015 14:06
Hello world, linux x86 assembly version
.section .rodata
.hellostr:
.string "Hello, world\n"
.text
.globl _start
_start:
pushq %rbp
movq %rsp, %rbp
@revmischa
revmischa / install-plenv.sh
Last active July 12, 2022 02:25
Set up plenv, install perl, cpanm, carton, set up environment
#!/bin/bash
# installs plenv, perl, carton, cpanminus, sets up environment in .bash_profile
# from https://github.com/tokuhirom/plenv#readme
PLENV_PERL_VERSION='5.18.1'
if [[ -n "$PERL_MB_OPT" ]]; then
echo "You must unset your local::lib environment variables first"
0000000100000f2e subq $8, %rsp
0000000100000f32 xorl %r12d, %r12d
0000000100000f35 leaq 68(%rip), %r14
0000000100000f3c movl $42, %r15d
new_line:
0000000100000f42 movswl (%r14,%r12,2), %r13d
0000000100000f47 xorl %ebx, %ebx
new_col:
0000000100000f49 btl %ebx, %r13d
0000000100000f4d movl $95, %edi
y/01/_*/,print for map{sprintf("%011b\n",$_)}(32,32,80,136,260,1539,260,136,80,32,32)
# 41558682057254037406452518895026208 = bitmap of 0=_,1=*, packed as 11-bit lines
# 11-bit chunks: 32 32 80 136 260 1539 260 136 80 32 32
# %011b gives:
# 00000100000
# 00000100000
# 00001010000
# 00010001000
# 00100000100
@revmischa
revmischa / ResultSet.pm
Last active December 19, 2015 17:38
DBIx::Class generic resultset method to take the current query and estimate a count of the rows returned. Use `->estimate_count` in place of `->count` to get a fast, approximate count of complex queries.
Add the following to your base ResultSet class:
# fast row estimation function for postgres
# similar to ->count, but may be much faster for Pg < 9.2
# uses query planner row count estimation, accuracy depends on when
# ANALYZE/autovacuum was last performed on the table
# more info: http://wiki.postgresql.org/wiki/Count_estimate
sub estimate_count {
my ($self) = @_;
@revmischa
revmischa / pglisten.c
Last active February 23, 2023 19:52
Example postgresql asynchronous connection with LISTEN handler
#include <stdio.h>
#include <stdlib.h>
#include <libpq-fe.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
// channel to LISTEN on
const char *listenChannel = "foo";
@revmischa
revmischa / ansi2unicode.pl
Created November 6, 2012 06:59
Convert raw ANSI to IRC or HTML
#!/usr/bin/perl
# ansi2unicode.pl
# 4/18/2007
#
# convert an ANSI file to unicode, suitable for display in irssi/mirc or html
# usage: ansi2unicode.pl inputfile [-tc] [-o outputmode] [outputfile]
# -t = terminal output, no color
# -o = output mode, currently only html and irc supported, default is irc
# outputfile = filename to output to if html specified
@revmischa
revmischa / elitedesktop.md
Last active October 2, 2015 23:57
Pimp Your Linux

THIS ASSUMES YOU RUN DEBIAN (or ubuntu, mint) AND ARE NOT A SUCKA MC

XDM

sudo aptitude install xdm pterm xtrlock
sudo echo '/usr/bin/xdm' > /etc/X11/default-display-manager

spectrwm, dmenu

sudo aptitude -y install dmenu libxtst-dev libxrandr-dev libxcursor-dev libxft-dev libx11-xcb-dev libxcb-util0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libxcb-xtest0-dev libxcb-randr0-dev libxt-dev
git clone git://opensource.conformal.com/spectrwm.git
cd spectrwm/linux

@revmischa
revmischa / install_panoptic.sh
Created March 15, 2012 03:51
Set up everything needed for panoptic
#!/bin/bash
INSTALLDIR="$HOME/local/panoptic"
function step() {
NAME=$1
if [[ -z "$NAME" ]]; then
echo "Function name required"
exit 1
@revmischa
revmischa / pubsub_munin.sh
Created January 17, 2012 00:27
Web::Hippie::PubSub munin plugin
GRAPH_TYPE='GAUGE'
if [ "$1" = "config" ]; then
echo 'graph_title Web::Hippie::PubSub subscribers'
echo 'graph_vlabel events'
echo 'graph_category HTTP'
echo 'current_subscribers.label current subscribers'
echo "current_subscribers.type $GRAPH_TYPE"