Skip to content

Instantly share code, notes, and snippets.

View TuralAsgar's full-sized avatar

Tural Asgar TuralAsgar

View GitHub Profile
@alexedwards
alexedwards / gist:dc3145c8e2e6d2fd6cd9
Last active April 9, 2024 05:30
Example of working with Go's database/sql and NULL fields
CREATE TABLE books (
isbn char(14) NOT NULL,
title varchar(255),
author varchar(255),
price decimal(5,2)
);
INSERT INTO books (isbn, title, author, price) VALUES
('978-1503261969', 'Emma', 'Jayne Austen', 9.44),
('978-1514274873', 'Journal of a Soldier', NULL, 5.49),
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
@kujiy
kujiy / git-bash.exe-args
Last active April 20, 2023 13:55
How to open a specific folder with git-bash.exe from a command line(shell)
With argument
"C:\Program Files\Git\git-bash.exe" "--cd=%1"
Direct
"C:\Program Files\Git\git-bash.exe" "--cd="C:\YOUR\FOLDER\"
@tabula-rasa
tabula-rasa / ckupload.go
Created November 20, 2015 19:25
Golang handler for Ckeditor image upload
package controllers
import (
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
@albulescu
albulescu / download.go
Created March 25, 2016 09:44
golang download file with progress
package main
/**
* @website http://albulescu.ro
* @author Cosmin Albulescu <cosmin@albulescu.ro>
*/
import (
"bytes"
"fmt"
@tanyuan
tanyuan / smart-caps-lock.md
Last active May 8, 2024 16:05
Smart Caps Lock: Remap Caps Lock to Control AND Escape

Smart Caps Lock: Remap to Control AND Escape (Linux, Mac, Windows)

Caps Lock 變成智慧的 Control 以及 Escape

  • 單獨輕按一下就是 Escape
  • 若按下時同時按著其他鍵,就會是 Control

這應該是 Vim 和 Emacs 的最佳解了!(Emacs? Bash 的快捷鍵就是 Emacs 系列的)

  • Send Escape if you tap Caps Lock alone.
@sosedoff
sosedoff / 1_simple.go
Created July 16, 2016 18:45
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
@ishanjain28
ishanjain28 / nginx
Last active September 5, 2017 22:13
# nginx reverse proxy configuration for hosting two websites on one server
# File has to be saved in /etc/nginx/sites-available/website
# Then link it and store that in ../sites-enabled
# Also this configuration can be used to enable https on a website, Remove the third server {} block.
server {
# Redirect from http to https
listen 80;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
[Unit]
Description=ServiceName
Documentation=https://example.com/doc.txt
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
Restart=on-failure
PermissionsStartOnly=true
User=programusername
@ale10257
ale10257 / menu.php
Last active August 31, 2020 11:57
Yii2 displaying a menu with an unlimited nesting level from Nested Sets
<?php
/**
* @var $this yii\web\View
* @var $categories \app\models\Category[]
* @var $level_start int
*/
use yii\helpers\Html;