Skip to content

Instantly share code, notes, and snippets.

@vulcangz
vulcangz / install_golang.sh
Created August 6, 2017 11:11 — forked from jniltinho/install_golang.sh
Install Golang on Linux
#!/bin/bash
## Install Golang 1.8 64Bits on Linux (Debian|Ubuntu|OpenSUSE|CentOS)
## http://www.linuxpro.com.br/2015/06/golang-aula-1-instalacao-da-linguagem-no-linux.html
## Run as root (sudo su)
## Thank's @geosoft1 | @gwmoura
GO_URL="https://storage.googleapis.com/golang"
GO_VERSION=${1:-"1.8.1"}
GO_FILE="go$GO_VERSION.linux-amd64.tar.gz"
@vulcangz
vulcangz / ResponsiveLinkPager.php
Created October 7, 2017 08:29 — forked from tanakahisateru/ResponsiveLinkPager.php
Bootstrap responsive pagination widget for Yii
<?php
namespace app\utils\widgets;
use yii\helpers\Html;
use yii\widgets\LinkPager;
/**
* ResponsiveLinkPager can reduce or style each buttons for responsive design.
*
* Define CSS classes as if maxButtonCount would be so. For example below applies hidden-xs class
@vulcangz
vulcangz / ManyManySupport.php
Created October 7, 2017 08:34 — forked from tanakahisateru/ManyManySupport.php
MANY_MANY relation support behavior for Yii framework
<?php
/**
* This behavior is for a model having one or more MANY-MANY relations.
*
* You need a junction table:
*
* CREATE_TABLE self_target (
* self_id integer(11) NOT NULL,
* target_id integer(11) NOT NULL,
* ...
@vulcangz
vulcangz / main.go
Created March 19, 2019 11:33 — forked from KeKsBoTer/main.go
Dice graph
package main
import (
"flag"
"fmt"
"math/big"
"strconv"
"github.com/ALTree/bigfloat"
)
@vulcangz
vulcangz / gist.go
Created July 15, 2019 09:00 — forked from alexedwards/gist.go
SCS v2 Multiple Sessions
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
"time"
"github.com/alexedwards/scs/v2"
@vulcangz
vulcangz / gist.go
Created July 15, 2019 09:35 — forked from alexedwards/gist.go
SCS v2 Manual Load and Save
package main
import (
"io"
"net/http"
"github.com/alexedwards/scs/v2"
)
var session = scs.NewSession()
@vulcangz
vulcangz / main.go
Created July 15, 2019 09:47 — forked from alexedwards/main.go
RequireLogin middleware
var sessionManager = scs.NewCookieManager("...")
func RequireLogin(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session := sessionManager.Load(r)
userID, err := session.GetInt("userID")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
@vulcangz
vulcangz / BMap.html
Created October 2, 2019 13:04 — forked from mcattx/BMap.html
百度地图 API 应用实例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
#mapBox {
width: 90%;
@vulcangz
vulcangz / Makefile
Created October 4, 2019 07:38 — forked from sighingnow/Makefile
Detect operating system in Makefile.
# Detect operating system in Makefile.
# Author: He Tao
# Date: 2015-05-30
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG += -D WIN32
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OSFLAG += -D AMD64
endif
@vulcangz
vulcangz / .babelrc
Created October 10, 2019 04:02 — forked from c9s/.babelrc
webpack + babel + typescript + es6 - total solutions!
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
}