Skip to content

Instantly share code, notes, and snippets.

// For example:
// UIColorFromRGBA(0xffee00, 0.5)
// UIColorFromRGB(0xffee00)
static inline UIColor *UIColorFromRGBA(int rgb, float a) {
return [UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0
green:((float)((rgb & 0xFF00) >> 8))/255.0
blue:((float)(rgb & 0xFF))/255.0 alpha:a];
}
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
// Inspired by suggestion to use NSScanner: http://stackoverflow.com/questions/1918972/camelcase-to-underscores-and-back-in-objective-c
#import "NSString+Inflections.h"
@implementation NSString (Inflections)
- (NSString *)underscore
{
NSScanner *scanner = [NSScanner scannerWithString:self];
scanner.caseSensitive = YES;

** 目前仅支持 MacOS ##

打开终端程序, 复制、粘贴、执行以下句子:

curl -s -I https://www.atom.io/api/updates/download --header 'User-Agent: Atom/0.1 CFNetwork/1.5'|grep '^Location:'| sed -e 's+^.*\(https://.*\)$+\1+g'

稍等片刻,会输出类似下面的一行内容:

#!/usr/bin/env perl
# Copyright (c) 2015 Sergey Lyubka
# All rights reserved
use Encode;
my $dir = "/Users/$ENV{USER}/.Trash";
sub read_file($) { local $/; open FD, $_[0] or die $_[0]; binmode FD; <FD>; }
require 'formula'
class Unzip < Formula
homepage 'http://www.info-zip.org/pub/infozip/UnZip.html'
url 'https://downloads.sourceforge.net/project/infozip/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz'
version '6.0'
sha1 'abf7de8a4018a983590ed6f5cbd990d4740f8a22'
keg_only :provided_by_osx
@zwf
zwf / surge_main.conf
Last active October 28, 2015 06:54 — forked from jason5ng32/surge.conf
Surge Configs ( Both 2 files are needed )
[General]
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24,100.64.0.0/10
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12,127.0.0.0/24,100.64.0.0/10
// DNS OVERRIDE, REMOVE # IF YOU NEED
dns-server = 119.29.29.29,223.6.6.6,223.5.5.5,114.114.114.114,114.114.115.115
[Rule]
@zwf
zwf / gist.md
Created August 24, 2016 15:26 — forked from bumaociyuan/gist.md
Stuck on `Authenticating with the App Store...`
@zwf
zwf / fix-homebrew-npm.md
Created March 24, 2017 16:53 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@zwf
zwf / install-docker-elementary-loki.sh
Created August 2, 2017 15:59 — forked from ChrisTimperley/install-docker-elementary-loki.sh
Installs Docker on Elementary OS 0.4 (Loki)
#!/bin/bash
sudo apt-get install apt-transport-https ca-certificates -y
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo rm -f /etc/apt/sources.list.d/docker.list
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install docker-engine