Skip to content

Instantly share code, notes, and snippets.

View timohuovinen's full-sized avatar
🙃

Timo Huovinen timohuovinen

🙃
View GitHub Profile
@wattanakorn495
wattanakorn495 / Makefile
Created May 6, 2022 04:28
dynamodb put example
build:
go mod tidy
GOOS=linux GOARCH=amd64 go build -o ./main ./main.go
zip -j ./main.zip ./main
rm ./main
clean:
rm main.zip
rm main
@cmpark0126
cmpark0126 / llvm-ir-gen.sh
Last active January 19, 2024 16:26
How to Generate LLVM IR from C Source Code?
#!/bin/bash
name=${1%.*c} # detatch .c from c file name
clang-9 -O0 -Xclang -disable-O0-optnone -fno-discard-value-names -emit-llvm -c $name.c # convert source code(.c) to bit code(.bc)
llvm-dis-9 $name.bc -o $name.ll # generate llvm ir(.ll) from bit code(.bc) obtained above without any optimization
opt-9 -mem2reg $name.bc -o $name.mem2reg.bc # optimize bit code using `mem2reg` optimization pass before generating llvm ir
llvm-dis-9 $name.mem2reg.bc -o $name.mem2reg.ll # generate llvm ir(.ll) from optimized bit code(.bc)
@abiosoft
abiosoft / .wslconfig
Last active March 31, 2022 08:07
wsl2 config
[wsl2]
kernel= # An absolute Windows path to a custom Linux kernel.
memory= # How much memory to assign to the WSL2 VM.
processors= # How many processors to assign to the WSL2 VM.
swap= # How much swap space to add to the WSL2 VM. 0 for no swap file.
swapFile= # An absolute Windows path to the swap vhd.
localhostForwarding= # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).
# entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel
# entries must be size followed by unit, for example 8GB or 512MB
@thiagozs
thiagozs / gomock.md
Last active April 19, 2024 03:45
Tutorial gomock

08/16/17 by  Sergey Grebenshchikov

No Comments

This is a quick tutorial on how to test code using the GoMock mocking library and the standard library testing package testing.

GoMock is a mock framework for Go. It enjoys a somewhat official status as part of the github.com/golang organization, integrates well with the built-in testing package, and provides a flexible expectation API.

wget -O /tmp/YaHei.Consolas.1.12.zip https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/uigroupcode/YaHei.Consolas.1.12.zip
unzip /tmp/YaHei.Consolas.1.12.zip
sudo mkdir -p /usr/share/fonts/consolas
sudo mv YaHei.Consolas.1.12.ttf /usr/share/fonts/consolas/
sudo chmod 644 /usr/share/fonts/consolas/YaHei.Consolas.1.12.ttf
cd /usr/share/fonts/consolas
sudo mkfontscale && sudo mkfontdir && sudo fc-cache -fv
@zhunik
zhunik / docker-compose.yml
Created September 14, 2018 15:12
docker-compose Postgres health-check
version: "3"
services:
postgress:
....
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
app:
@pseudomuto
pseudomuto / main_1.go
Last active May 4, 2024 00:30
Blog Code: Clean SQL Transactions in Golang
package main
import (
"database/sql"
"log"
)
func main() {
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE")
handleError(err)
@andrewmilson
andrewmilson / file-upload-multipart.go
Last active April 24, 2024 10:27
Golang multipart/form-data File Upload
package main
import (
"net/http"
"os"
"bytes"
"path"
"path/filepath"
"mime/multipart"
"io"
@alixaxel
alixaxel / sqlite.udf.like.icu.php
Last active September 22, 2021 19:03
SQLite UDFs for LIKE Operator Overloading
<?php
$db->sqliteCreateFunction('like',
function ($pattern, $data, $escape = null) use ($db)
{
static $modifiers = null;
if (isset($modifiers) !== true)
{
$modifiers = ((strncmp($db->query('PRAGMA case_sensitive_like;')->fetchColumn(), '1', 1) === 0) ? '' : 'i') . 'suS';
@rogerleite
rogerleite / install_monaco_font.sh
Last active April 27, 2024 05:27
Install Monaco font in Linux
#!/bin/bash
# Install Monaco font in Linux
# Version from nullvideo https://gist.github.com/rogerleite/99819#gistcomment-2799386
sudo mkdir -p /usr/share/fonts/truetype/ttf-monaco && \
sudo wget https://gist.github.com/rogerleite/b50866eb7f7b5950da01ae8927c5bd61/raw/862b6c9437f534d5899e4e68d60f9bf22f356312/mfont.ttf -O - > \
/usr/share/fonts/truetype/ttf-monaco/Monaco_Linux.ttf && \
sudo fc-cache