Skip to content

Instantly share code, notes, and snippets.

View tamadamas's full-sized avatar
☯️
Love Zig

Tomas Tamadamas tamadamas

☯️
Love Zig
View GitHub Profile
@komasaru
komasaru / prime_number_1.rb
Last active January 18, 2022 23:21
Ruby script to check a prime number.
#! /usr/local/bin/ruby
# coding: utf-8
# --------------------------------------
# Check a prime number
# --------------------------------------
def is_prime(n)
res = (2..Math.sqrt(n)).any? { |i| n % i == 0 }
puts "#{n}: #{res || n == 1 ? '-----' : "PRIME"}"
end
@P7h
P7h / tmux__CentOS__build_from_source.sh
Last active October 11, 2025 01:02
tmux 2.0 and tmux 2.3 installation steps for Ubuntu. Or build from tmux source v2.5 for Ubuntu and CentOS.
# Steps to build and install tmux from source.
# Takes < 25 seconds on EC2 env [even on a low-end config instance].
VERSION=2.7
sudo yum -y remove tmux
sudo yum -y install wget tar libevent-devel ncurses-devel
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz
tar xzf tmux-${VERSION}.tar.gz
rm -f tmux-${VERSION}.tar.gz
cd tmux-${VERSION}

Keybase proof

I hereby claim:

  • I am reisub on github.
  • I am dino_kovac (https://keybase.io/dino_kovac) on keybase.
  • I have a public key ASDjRLKia8PlTVhq4TrhoXoDvU1OEHEFKL1qz5t9TyuPGgo

To claim this, I am signing this object:

@geddski
geddski / config.fish
Created October 3, 2014 19:42
useful fish config for git
##----GIT------
alias gs='clear ;and git status'
alias gb='git branch'
alias gbranch='git rev-parse --abbrev-ref HEAD' #get current branch name
alias gl="clear ;and git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gt='git tag'
alias grm='git rm'
alias gps='git push'
alias gbi='git bisect'
alias gbg='git bisect good'
@profh
profh / decode_session_cookie.rb
Last active January 9, 2025 12:23
A simple script to decode Rails 4 session cookies
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['backbone.marionette', 'backbone.radio', 'underscore'], factory);
} else if (typeof exports !== 'undefined') {
module.exports = factory(require('backbone.marionette'), require('backbone.radio'), require('underscore'));
} else {
factory(root.Backbone.Marionette, root.Backbone.Radio, root._);
}
}(this, function(Marionette, Radio, _) {
'use strict';
numbers = %w(zero one two three four five six seven eight nine)
operations = {
'minus' => '-',
'plus' => '+',
'times' => '*',
'divided_by' => '/'
}
(0..9).each do |number|
@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@staltz
staltz / introrx.md
Last active November 11, 2025 05:59
The introduction to Reactive Programming you've been missing
@Kartones
Kartones / postgres-cheatsheet.md
Last active November 8, 2025 15:12
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)