Skip to content

Instantly share code, notes, and snippets.

@jbuchbinder
jbuchbinder / string_to_ascii.go
Created May 3, 2013 20:39
Convert UTF-8 Go strings to ASCII bytes.
package main
import (
"unicode/utf8"
)
// Fake converting UTF-8 internal string representation to standard
// ASCII bytes for serial connections.
func StringToAsciiBytes(s string) []byte {
t := make([]byte, utf8.RuneCountInString(s))
#!/bin/bash
# function Extract for common file formats
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
else
if [ -f "$1" ] ; then
NAME=${1%.*}
@csotomon
csotomon / Vagrantfile
Last active April 5, 2024 13:48
Vagrant ubuntu with mysql server
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@bndw
bndw / readme.md
Last active May 20, 2023 02:32
go 1.10 encoding/json Decoder.DisallowUnknownFields

Go 1.10 was released today and an addition to the core library encoding/json package caught my eye

func (dec *Decoder) DisallowUnknownFields()

DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.

Godoc

@ekibun
ekibun / auth.js
Last active May 23, 2020 15:43
auth demo for bgm.tv
/*
* @Description: auth demo for bgm.tv
* @Author: ekibun
* @Date: 2019-06-30 16:42:16
* @LastEditors: ekibun
* @LastEditTime: 2019-07-08 01:41:10
*/
const axios = require('axios')
const cheerio = require('cheerio')
const qs = require('qs')
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.