Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
data=$(timeout 20 gatttool -b $SENSOR_ADDRESS --char-write-req --handle=0x10 -n 0100 --listen 2>/dev/null | grep "Notification handle" -m 2)
temperature=$(echo $data | awk '{print $7$6}')
humidity=$(echo $data | awk '{print $8}')
temperature=$((16#$temperature))
temperature=$(echo "scale=2; $temperature/100" | bc -l)
humidity=$((16#$humidity))
echo $temperature
echo $humidity
@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
@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
@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]}");
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);
#!/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)
#!/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
@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.

@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 / 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):