I'm quite confused as there seems to be multiple redundant ways to solve my problem (read a file, parse the content, serve it via http). Most people on stackoverflow would use bufio, but I just can't get the differences between this package and the Buffer type of bytes and just reading a file with the os methods. Also I don't know when and why I should choose those ways to do it, when I have the simple, but non-versatile, ioutils.ReadFile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ES7, async/await | |
| function sleep(ms = 0) { | |
| return new Promise(r => setTimeout(r, ms)); | |
| } | |
| (async () => { | |
| console.log('a'); | |
| await sleep(1000); | |
| console.log('b'); | |
| })() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| for i in ./*.swf ; do | |
| for j in `swfextract $i | grep -E PNGs.* -o | grep -E [0-9]+ -o` ; do | |
| echo "$i -> extract png $j"; | |
| swfextract -p "$j" "$i" -o "$i"_"$j".png | |
| done | |
| for j in `swfextract $i | grep -E JPEGs.* -o | grep -E [0-9]+ -o` ; do | |
| echo "$i -> extract jpeg $j"; | |
| swfextract -j "$j" "$i" -o "$i"_"$j".jpg | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // You need to apply this once all the animations are already finished. Otherwise labels will be placed wrongly. | |
| d3.selectAll('.nv-multibar .nv-group').each(function(group){ | |
| var g = d3.select(this); | |
| // Remove previous labels if there is any | |
| g.selectAll('text').remove(); | |
| g.selectAll('.nv-bar').each(function(bar){ | |
| var b = d3.select(this); | |
| var barWidth = b.attr('width'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [General] | |
| loglevel = notify | |
| skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local, ::ffff:0:0:0:0/1, ::ffff:128:0:0:0/1 | |
| bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12 | |
| # dns-server = 119.29.29.29,223.5.5.5,114.114.115.115 | |
| # external-controller-access = [email protected]:6155 | |
| # ipv6 = true | |
| // REMEMBER TO CHANGE THE external-controller-access' PASSWORD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.graphics.Bitmap; | |
| import android.graphics.BitmapFactory; | |
| import android.graphics.drawable.BitmapDrawable; | |
| import android.util.Log; | |
| import java.io.ByteArrayInputStream; | |
| import java.io.ByteArrayOutputStream; | |
| import java.io.IOException; | |
| import java.nio.ByteBuffer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # On slow systems, checking the cached .zcompdump file to see if it must be | |
| # regenerated adds a noticable delay to zsh startup. This little hack restricts | |
| # it to once a day. It should be pasted into your own completion file. | |
| # | |
| # The globbing is a little complicated here: | |
| # - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct. | |
| # - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error) | |
| # - '.' matches "regular files" | |
| # - 'mh+24' matches files (or directories or whatever) that are older than 24 hours. | |
| autoload -Uz compinit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The first script tag is optional if you start with javascript | |
| //<script> | |
| $(document).ready(function () { | |
| $("body").append("<br>jQuery said AngularJS rocks!"); | |
| alert($(document).html()); | |
| }); | |
| angular.module('PricesApp', []) | |
| .controller("PriceController", function () { |