Skip to content

Instantly share code, notes, and snippets.

View alwqx's full-sized avatar
🎯
Focusing

alwqx

🎯
Focusing
View GitHub Profile
const s = document.createElement('script');
s.setAttribute(
'src',
'https://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js'
);
document.head.appendChild(s);
const sall = () => {
try {
$('a[action-type="batselect"]')[0].click();
@alwqx
alwqx / go-text-remove-extra-line.go
Last active February 7, 2017 10:22
go text remove extra space of script output
package main
import(
"os/exec"
"os"
"fmt"
)
func main() {
devices := getDevices()
fmt.Println(devices)
@alwqx
alwqx / go-text-fields-vs-split.go
Last active February 7, 2017 10:16
golang deal with text
package main
import(
"strings"
"fmt"
)
func main() {
lines := "194 Temperature_Celsius 0x0022 037 045 000 Old_age Always - 37 (0 6 0 0 0)"
useSplit(lines)
@alwqx
alwqx / cassandra-replace-primary-key-value.py
Created January 17, 2017 08:19
cassandra replace primary key value
"""
# table schema
CREATE TABLE raw.disk_storage (
machine_id text,
date date,
timestamp timestamp,
available bigint,
total bigint,
used bigint,
PRIMARY KEY ((machine_id, date), timestamp)
package main
import (
"bytes"
"encoding/json"
"fmt"
client "github.com/docker/engine-api/client"
"github.com/docker/engine-api/types"
"log"
"os"
@alwqx
alwqx / Timestamp2Date.scala
Last active June 29, 2017 12:02
convert timestamp to Date or string in Scala
import java.util.Date
import java.text.SimpleDateFormat
object TS2Date {
def main(args: Array[String]): Unit = {
val ts:BigInt = 1480665459
val df:SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
val date:String = df.format(ts.toLong)
//ret: String = 1970-01-18
}
}
@alwqx
alwqx / deltatime.go
Last active December 29, 2016 02:13
用Golang计算某时刻前n秒的时间
package utils
import(
"fmt"
"time"
)
func SubIntervalTime(interval int64) string {
t0 := time.Now()
fmt.Println("t0:", t0.Format("2006-01-02 15:04:05"))
@alwqx
alwqx / diskusage.go
Last active January 16, 2021 12:03
calculate disk usage in golang (Linux only) by parse output of command `df`
import(
"fmt"
"strconv"
"strings"
"os/exec"
"log"
)
func main() {
out, _ := exec.Command("df", "-P").Output()