Skip to content

Instantly share code, notes, and snippets.

View adeishs's full-sized avatar

ade ishs adeishs

View GitHub Profile
@adeishs
adeishs / jquery-lining-up-table-cols.js
Last active March 8, 2018 23:13
Lining Up Table Columns with jQuery
<script type="text/javascript">
$(function() {
var widths = new Array;
/* get max column widths from tables */
$('table').each(function() {
i = 0;
$(this).find('thead th').each(function() {
w = $(this).width();
@adeishs
adeishs / hashref-hashref.pl
Last active March 21, 2018 01:37
Perl hashref of hashref
#!/usr/bin/perl
use strict;
use Data::Dumper;
my $x;
$x->{a}->{b}->{c}->{d} = 1;
print Dumper($x)
=begin output
@adeishs
adeishs / multilevel-dict-broken.py
Created March 21, 2018 00:27
Multilevel Dictionary (Broken)
#!/usr/bin/env python
x = {}
x['a']['b']['c']['d'] = 1
@adeishs
adeishs / multilevel-dict-solution.py
Last active March 21, 2018 01:08
Multilevel Dictionary (Solution)
#!/usr/bin/env python
import collections
import pprint
dict_factory = lambda: collections.defaultdict(dict_factory)
x = collections.defaultdict(dict_factory)
x['a']['b']['c']['d'] = 1
print x['a']['b']['c']['d']
print pprint.pformat(x) # looks a bit messy, but it gives you the idea
@adeishs
adeishs / .vimrc
Last active December 1, 2018 11:00
My .vimrc
execute pathogen#infect()
colorscheme borland
set nu
set title
set guifont=Source\ Code\ Pro:h13
set termencoding=utf-8
set encoding=utf-8
set fileencoding=utf-8
set shiftwidth=4 softtabstop=4 smarttab expandtab
set colorcolumn=80
@adeishs
adeishs / .bash_profile
Created November 29, 2018 00:11
My .bash_profile
#!/bin/bash
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
source ~/git-completion.bash
# https://perlbrew.pl/
source ~/perl5/perlbrew/etc/bashrc

Keybase proof

I hereby claim:

  • I am adeishs on github.
  • I am adeishs (https://keybase.io/adeishs) on keybase.
  • I have a public key ASDQlVBSXewGedj1Ivd9i-shtY31suJQLNx4RrpyVqvNcgo

To claim this, I am signing this object:

@adeishs
adeishs / list-slurp-fix.pl
Last active August 4, 2020 00:22
Perl list slurp
#!/usr/bin/env perl
use strict;
use List::Util qw(any);
use Data::Dumper::Concise;
my %h = (
k1 => {
s1 => 0,
s2 => 0,
@adeishs
adeishs / uniq-sort.pl
Created March 3, 2021 00:42
Not uniquely sorted
#!/usr/bin/env perl
use List::MoreUtils;
use Data::Dumper::Concise;
my @els = qw(e a p c x e e x);
my @not_uns = sort List::MoreUtils::uniq @els;
my @uns = sort { $a cmp $b } List::MoreUtils::uniq @els;
@adeishs
adeishs / pg-get-first-monday.sql
Created September 30, 2022 00:11
Get the first Monday of a year
-- get the first Monday of a year
WITH year AS (
-- change the year as you need
SELECT CAST(2022 AS INTEGER) y
),
first_date AS (
SELECT CAST(y || '-01-01' AS DATE) AS d
FROM year
)