Skip to content

Instantly share code, notes, and snippets.

@cbuctok
cbuctok / generate_random_thing.py
Last active October 12, 2016 14:18
Random py2
import string
from random import sample, choice
chars = string.letters + string.digits
print ''.join(choice(chars) for _ in range(4))
@cbuctok
cbuctok / build-zsh.sh
Created January 16, 2018 15:33
Build last stable version of ZSH from sources on Ubuntu, or any other version with small changes
#!/bin/bash
# Build Zsh from sources on Ubuntu.
# From http://zsh.sourceforge.net/Arc/git.html and sources INSTALL file.
# Make script gives up on any error
set -e
# Some packages may be missing
sudo apt-get install -y git-core gcc make autoconf yodl libncursesw5-dev texinfo checkinstall
@cbuctok
cbuctok / zsh_to_fish.py
Created February 1, 2018 08:20 — forked from dvdbng/zsh_to_fish.py
Migrate zsh history to fish
import os
import re
def zsh_to_fish(cmd):
return (cmd.replace('&&', '; and ')
.replace('||', '; or '))
def is_valid_fish(cmd):
@cbuctok
cbuctok / merge-subtitles.py
Created February 18, 2018 16:16 — forked from NamPNQ/merge-subtitles.py
Python Merge two subtitles
#!/usr/bin/python3
# -*- coding: utf8 -*-
# ----------------------------------------------------------------------------
# Name: merge-subtitles
# Desc: Merge two subtitles
# Usage: merge-subtitles sub1_file sub2_file out.ass
# Example: merge_subtitles friends_s01e01_720p_bluray_x264-sujaidr.mp4en.srt friends_s01e01_720p_bluray_x264-sujaidr.mp4vi.srt friends_s01e01_720p_bluray_x264-sujaidr.mp4.ass
# Copy From: https://github.com/duyamin/standalone-scripts/blob/master/python/merge-subtitles.py
# ----------------------------------------------------------------------------
@cbuctok
cbuctok / install_elixir.md
Last active April 2, 2018 11:08 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
#!/usr/bin/python3
import sys
import telepot
message = "NONE"
TOKEN = TOKEN
id = ID
if (len(sys.argv) < 2):
print("whatdotbot MESSAGE")
else:
bot = telepot.Bot(TOKEN)
using System;
using System.Linq;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
var s = new List<int> { 1,2,3,34,5,678,8,5,4,5,7,8,7,4,3,3,6,8,4};
var groups = s.Select((value,index)=>new { Value= value,Index=index}).GroupBy(i=>i.Index/2,v=>v.Value);
@cbuctok
cbuctok / gist:97b62b8ff519efa6ed03617843d5f353
Last active July 25, 2019 11:24
Lists: next element or first
//element = list[index == -1 ? 0 : index % list.Count];
currentStep++;
Console.WriteLine($"{list[currentStep == -1 ? 0 : currentStep % list.Length]}");
@cbuctok
cbuctok / golang_project-layout_for_poor.sh
Created November 2, 2019 12:31
Standard Go Project Layout for poor
array=("api" "assets" "build" "cmd" "configs" "deployments" "docs" "examples" "githooks" "init" "internal" "pkg" "scripts" "test" "third_party" "tools" "vendor" "web" "website")
for d in ${array[*]};
do
mkdir $d
done