This file contains 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
#!/usr/bin/env node | |
const TextToSVG = require('text-to-svg'); | |
const path = require('path'); | |
const puppeteer = require('puppeteer'); | |
// Render a text into .svg file | |
// | |
// $ svgtext.js font.ttf Hello | |
// <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://... |
This file contains 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
#!/usr/bin/env node | |
const path = require('path'); | |
const puppeteer = require('puppeteer'); | |
// Get bounding box of an svg | |
// | |
// $ node app_svgbbox.js a.svg | |
// 2.74 -61.85 180.86 62.43 |
This file contains 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
<?php | |
// Clone an object, then alter it a little | |
// | |
// Object Cloning | |
// http://php.net/manual/en/language.oop5.cloning.php | |
// | |
// Magic Methods | |
// http://www.php.net/manual/en/language.oop5.magic.php |
This file contains 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
<?php | |
# Generic way to call base class constructor | |
class Foo | |
{ | |
public function __construct() | |
{ | |
echo "FOO\n"; | |
} |
This file contains 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/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# Using fg command | |
# https://www.gnu.org/software/bash/manual/html_node/Job-Control-Basics.html | |
# Enable job control. Otherwise, `fg` will yield "fg: no job control" |
This file contains 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/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# Sending POST|PUT|PATCH|DELETE requests with curl | |
# https://ec.haxx.se/http-post.html | |
# https://curl.haxx.se/docs/manpage.html |
This file contains 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/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# POST as multipart/form-data with curl | |
# https://curl.haxx.se/docs/manpage.html | |
# Send name=value (`<`, `@`, and `;` in value has special meaning) |
This file contains 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
// Generate page numbers like Amazon does | |
// | |
// The algorithm: | |
// 1) Represent a result as three ranges: first, middle, last | |
// 2) Merge three ranges into single array, sort then remove duplicates. | |
// 3) Insert N between two adjacent numbers with values N-1 and N+1. | |
// 4) Insert ... between two adjacent numbers with difference more than 1. | |
// | |
// Inspired by https://gist.github.com/kottenator/9d936eb3e4e3c3e02598 |
This file contains 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/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# POST as application/x-www-form-urlencoded with curl | |
# https://curl.haxx.se/docs/manpage.html | |
# No encoding will be made at all. If contents are taken from a file |
This file contains 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/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# Truncate files | |
# Shrink existing file to 4096 bytes | |
truncate -s 4K foo |