Skip to content

Instantly share code, notes, and snippets.

View ik5's full-sized avatar
🎯
Focusing

ik5 ik5

🎯
Focusing
View GitHub Profile
@ik5
ik5 / optimize_jpg.sh
Last active August 29, 2015 14:13
Optimize big jpg scans using imagemagic and jpgoptim programs
#/usr/bin/env bash
shopt -s nocasematch
function exec_code() {
file=$1
ext=${file: -4}
if [[ $ext == '.jpg' ]]; then
echo ', a jpeg file, working on it'
mv "$file" "old_$file"
@ik5
ik5 / append_list.go
Last active August 29, 2015 14:18
Example on how to add items to a list based on struct
package main
import "fmt"
type SiteList struct {
Title string
Address string
FeedAddress string
Author string
}
@ik5
ik5 / rabbit_dispatcher.go
Created July 5, 2015 14:52
attempted load on rabbit
package main
import (
"flag"
"fmt"
"log"
"github.com/streadway/amqp"
)
@ik5
ik5 / fragment_count.go
Last active August 29, 2015 14:26
Calculating how many SMS fragments will a message have
package main
import (
"fmt"
"math"
"os"
"unicode/utf8"
)
func calculateSmsFragments(message string) uint64 {
@ik5
ik5 / gsm0338.go
Created August 18, 2015 09:46
Functions to convert between UTF8 and GSM 03.38 in go
package main
import (
"fmt"
"regexp"
"strings"
)
var utf8GsmChars = map[string]string{
`@`: "\x00", `£`: "\x01", `$`: "\x02",
@ik5
ik5 / gist:65de721ca495fa1bf451
Last active August 5, 2020 11:58 — forked from bradleypeabody/gist:185b1d7ed6c0c2ab6cec
golang, convert UTF-16 to UTF-8 string
package main
import "fmt"
import "unicode/utf16"
import "unicode/utf8"
import "bytes"
func main() {
b := []byte{
@ik5
ik5 / colors.go
Last active January 3, 2025 00:23
Simple golang expirement with ANSI colors
package main
// http://play.golang.org/p/jZ5pa944O1 <- will not display the colors
import "fmt"
const (
InfoColor = "\033[1;34m%s\033[0m"
NoticeColor = "\033[1;36m%s\033[0m"
WarningColor = "\033[1;33m%s\033[0m"
ErrorColor = "\033[1;31m%s\033[0m"
DebugColor = "\033[0;36m%s\033[0m"
@ik5
ik5 / conf.json
Created January 2, 2016 15:12
An example for dynamic configuration loading in ruby (using json)
{
"key1": "string",
"key2": true,
"key3": 10,
"nested": {
"nested_key1": [1]
}
}
@ik5
ik5 / uuid_regex.rb
Last active May 26, 2016 09:02
small regex to find a uuid in a sting
puts $1 if str =~ /([a-fA-F\d]{8}(-[a-fA-F\d]{4}){3}-[a-fA-F\d]{12}?)/
@ik5
ik5 / empty_string.c
Last active July 5, 2016 12:46
example on how to validate if a dynamic array of chars is empty
#include <stdio.h>
#include <string.h>
int empty_string(char * str) {
return(str == NULL || strlen(str) == 0 );
}
int main(int argc, char **argv) {
char * ch = NULL;