Skip to content

Instantly share code, notes, and snippets.

@disq
disq / Makefile
Last active Jun 2, 2020
Makefile for golang
View Makefile
#
# Generic Go project makefile
#
# Example:
# make PREFIX= DESTDIR=/tmp/project-name-build install
#
# PREFIX is mostly unused, it would be used to expose the installation path to installed files
# For now, running "make install" with PREFIX= is OK (as long as DESTDIR is set)
#
# For capistrano, it would be something like this:
@disq
disq / examplepool.go
Created Jan 24, 2017
example for issue 18081
View examplepool.go
package examplepool
import (
"context"
"errors"
"fmt"
"sync"
"time"
_ "github.com/alexbrainman/odbc"
@disq
disq / trtspor.js
Last active Oct 12, 2017
TRTspor canli yayin ekrani fix
View trtspor.js
// http://www.trtspor.com.tr/canli-yayin-izle/trt-spor-159/
$(".video-single .video-source").css("width", "1280px");$("#wrapper .top-navigation,.all_wrapper .header, .bar, .content, .footer").add($(".video-source > div")[1]).remove();$("body,.all_wrapper,.video-detail").css("background","#000000");
View main.go
package main
import (
"fmt"
"database/sql"
"time"
_ "github.com/VoltDB/voltdb-client-go/voltdbclient"
)
@disq
disq / go.mk
Created Nov 11, 2016
Makefile defaults file for generic Go projects (golang)
View go.mk
#
# Generic Go project makefile defaults file
#
# Usage:
#
# Renaming this file to "Makefile" and running "make" should just work.
# But you can also override one or more recipes:
#
# - Include this file with "include go.mk" as the first line of your custom Makefile
# - Define recipes using SRCDIR, GOROOT, GCFLAGS, LDFLAGS
@disq
disq / gpu-monitor.sh
Created May 28, 2011
GPU Monitor to send mail when load drops to 0%
View gpu-monitor.sh
#!/bin/sh
RET=`DISPLAY=:0 aticonfig --odgc --adapter=all`
ZEROCNT=`echo ${RET}|grep GPU|grep "0%"|wc -l`
if [ $ZEROCNT -gt 0 ]; then
if [ -e ~/gpu-monitor.stop ]; then
echo "$ZEROCNT gpu still idle"
exit 0
fi
sleep 10
RET=`DISPLAY=:0 aticonfig --odgc --adapter=all`
@disq
disq / gcd.sh
Last active Jan 2, 2017
gcd: cd in GOPATH
View gcd.sh
# Put this in ~/.bash_profile
# https://gist.github.com/disq/42459b522836b25f30469b3acb5500bf
gcd() {
if [[ "$1" == "" || "$2" != "" ]]; then
echo "Usage: gcd <dir in gopath>"
return 1
fi
FINDIN=${GOPATH}/src
View generate.go
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
View scan.go
import (
"bufio"
"context"
"io"
)
type CancelableScanner struct {
*bufio.Scanner
data chan string
err chan error
View group_concat.awk
#!/usr/bin/awk -f
function init() {
# allow max 50 fields
for(i=0;i<50;i++) {
last_data[i][""] = "";
split("", last_data[i]); # make it an array
}
}
function dump() {