Value | Color |
---|---|
\e[0;30m | Black |
\e[0;31m | Red |
\e[0;32m | Green |
\e[0;33m | Yellow |
\e[0;34m | Blue |
\e[0;35m | Purple |
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/swift sh | |
import Foundation | |
import PromiseKit // @mxcl ~> 6.5 | |
import Swifter // @mattdonnelly == b27a89 | |
let swifter = Swifter( | |
consumerKey: "FILL", | |
consumerSecret: "ME", | |
oauthToken: "IN", | |
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.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
extension UIImage { | |
func blurred(radius: CGFloat) -> UIImage { | |
let ciContext = CIContext(options: nil) | |
guard let cgImage = cgImage else { return self } | |
let inputImage = CIImage(cgImage: cgImage) | |
guard let ciFilter = CIFilter(name: "CIGaussianBlur") else { return self } | |
ciFilter.setValue(inputImage, forKey: kCIInputImageKey) | |
ciFilter.setValue(radius, forKey: "inputRadius") | |
guard let resultImage = ciFilter.value(forKey: kCIOutputImageKey) as? CIImage else { return self } |
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
extension UIImage { | |
func darkened() -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(size, false, 0) | |
defer { UIGraphicsEndImageContext() } | |
guard let ctx = UIGraphicsGetCurrentContext(), let cgImage = cgImage else { | |
return nil | |
} | |
// flip the image, or result appears flipped |
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/sh | |
# Just copy and paste the lines below (all at once, it won't work line by line!) | |
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY! | |
function abort { | |
echo "$1" | |
exit 1 | |
} | |
set -e |
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
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 750 500" preserveAspectRatio="xMidYMax slice"> | |
<defs> | |
<!-- Scene 1 Gradient --> | |
<linearGradient id="grad1" x1="-154.32" y1="263.27" x2="-154.32" y2="374.3" | |
gradientTransform="matrix(-1, 0, 0, 1.36, 231.36, -100.14)" gradientUnits="userSpaceOnUse"> | |
<stop offset="0.07" stop-color="#9c536b" /> | |
<stop offset="0.98" stop-color="#d98981" /> | |
</linearGradient> | |
<radialGradient id="bg_grad" cx="375" cy="-35" r="318.69" gradientUnits="userSpaceOnUse"> | |
<stop offset="0.1" stop-color="#F5C54E" id="sun" /> |
from http://stackoverflow.com/questions/111102/how-do-javascript-closures-work/6472397#6472397
I'm a big fan of analogy and metaphor when explaining difficult concepts, so let me try my hand with a story.
Once upon a time:
There was a princess...
function princess() {
In your command-line run the following commands:
brew doctor
brew update
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
# Take a very large number and pretty print it in triplets of 3 digits, each triplet separated by a space. | |
def pnum_spc(n): print(' '.join([''.join(list(str(n))[::-1][i:i+3]) for i in range(0, len(str(n)), 3)][::-1])) | |
# >>> pnum_spc(32 ** 13) | |
# 36 893 488 147 419 103 232 | |
# Print numbers as 32-bit binary numbers w/ spaces giving 4-bit words | |
def pbin_spc(n): print(' '.join([''.join(list(f'{n:032b}')[::-1][i:i+4][::-1]) for i in range(0, len(f'{n:032b}'), 4)][::-1])) | |
# >>> "{0:032b}".format(1234) | |
# '00000000000000000000010011010010' | |
# >>> pbin_spc(1234) |
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
package main | |
import ( | |
"fmt" | |
"reflect" | |
"strings" | |
) | |
// The goal: allow assignment to a go struct field based on the name that field | |
// is tagged with (specifically it's json-tagged name). |
NewerOlder