Skip to content

Instantly share code, notes, and snippets.

@komasaru
komasaru / Mysql.cpp
Created August 17, 2014 05:54
C++ source code to connect to MariaDB(MySQL).
/*
* Example to connect to MariaDB(MySQL)
*/
#include <iostream>
#include <mysql/mysql.h> // require libmysqlclient-dev
#include <string>
using namespace std;
/*
@nauhygon
nauhygon / Build Emacs for Windows 64bit with Native Compilation.md
Last active June 30, 2025 02:21
Step-by-step instructions to build Emacs for Windows 64 bit with MSYS2 and MinGW-w64. Now `native-comp` supported.

Build Emacs-w64 with MSYS2/MinGW-w64 with Native Compilation

Instructions are modified from emacs-w64 Wiki page by zklhp. Many thanks for sharing!

  1. Download the latest MSYS2 from this download page.

  2. Install MSYS2 to, for example, C:\msys2 (make sure no space in path to avoid unwanted problems).

  3. Optionally prettify the MSYS2 console mintty with ~/.minttyrc to make it more pleasing to eyes. Thanks to this awesome theme!

# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@komasaru
komasaru / chudnovsky.cpp
Last active April 21, 2024 09:10
C++ source code to compute pi with Chudnovsky formula and Binary Splitting Algorithm using GMP libarary.
/***************************************************************
* Computing pi by Binary Splitting Algorithm with GMP libarary.
**************************************************************/
#include <cmath>
#include <iostream>
#include <fstream>
#include <gmpxx.h>
using namespace std;
@shahrilnet
shahrilnet / pi.c
Created July 26, 2015 05:34
Implementation of Chudnovsky's algorithm to calculate approximation of Pi using C
#include <stdio.h>
#include <math.h>
#define SIZE 100
unsigned __int128 fact(int N) // calculate factorial with O(n)
{
static unsigned __int128 memo[SIZE] = {-1};
if(memo[N] > -1) return memo[N];
else return memo[N] = (N <= 1) ? 1 : fact(N-1) + fact(N-2);
@gonzaloserrano
gonzaloserrano / log.go
Created August 18, 2015 17:56
logrus wrapper
package log
import (
"fmt"
"github.com/Sirupsen/logrus"
"runtime"
"strings"
)
var logger = logrus.New()
@zchee
zchee / cgo.md
Last active June 20, 2025 08:51
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@Zenithar
Zenithar / Caddyfile
Last active July 21, 2019 21:06
Hugo + Caddy + Webhook
0.0.0.0:2015
root blog.zenithar.org/public
ext .html
gzip
git github.com/zenithar/zenithar.hugo {
path ../
hook /_admin/github/hook/zenithar.org secret
#! /bin/sh
GOOS=linux go build -o $2 "$1"
GOOS=linux go build -ldflags="-s -w" -o $2.-sw "$1"
upx -f --brute -o $2.upx $2
upx -f --brute -o $2.-sw.upx $2.-sw
GOOS=linux gotip build -o $2.tip "$1"
GOOS=linux gotip build -ldflags="-s -w" -o $2.tip.-sw "$1"
upx -f --brute -o $2.tip.upx $2.tip
@guyskk
guyskk / shadowsocks-server.service
Last active February 17, 2025 05:49
shadowsocks server systemd service
[Unit]
Description=Shadowsocks Server
After=network.target
[Service]
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks/ss-config.json
Restart=on-abort
[Install]
WantedBy=multi-user.target