Skip to content

Instantly share code, notes, and snippets.

@nunomorgadinho
nunomorgadinho / gist:b2d8e5b8f5fec5b0ed946b24fa288a91
Created February 10, 2017 13:30
PHPCS + WordPress Coding Standards
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@yuki-takeichi
yuki-takeichi / set-hostname.patch
Created July 13, 2016 06:06
Configuring FQDN for GCE instance
diff -Naur before/usr/share/google/set-hostname after/usr/share/google/set-hostname
--- before/usr/share/google/set-hostname 2016-03-16 18:30:48.000000000 +0900
+++ after/usr/share/google/set-hostname 2016-03-16 18:34:57.000000000 +0900
@@ -14,6 +14,9 @@
# Deal with a new hostname assignment.
+# *** The below line is added by patching. ***
+new_host_name=$(curl --fail --silent http://metadata/computeMetadata/v1/instance/attributes/hostname -H "Metadata-Flavor: Google")
+
@cjcullen
cjcullen / SessionAffinity
Last active December 8, 2015 23:23
Workaround for GCE LB Issue
Work around GCE LB issue by setting service session affinity by adding:
"sessionAffinity": "ClientIP"
to the service spec. This will give you sticky sessions, but will get GCE external LB services again.
@pai911
pai911 / UINavigationBarTaller.swift
Last active August 27, 2016 19:16
Custom Navigation Bar with increased height (tested on iOS 8.0)
//
// UINavigationBarTaller.swift
//
import UIKit
class UINavigationBarTaller: UINavigationBar {
///The height you want your navigation bar to be of
static let navigationBarHeight: CGFloat = 64
@tmspzz
tmspzz / ParameterEncodingExt.swift
Last active October 24, 2017 10:43
Alamofire-GZIP-ParameterEncoding
// Actual gzipping from https://github.com/1024jp/NSData-GZIP
// Example: ParameterEncoding.JSON.gzipped
infix operator • { associativity left }
func • <A, B, C>(f: B -> C, g: A -> B) -> A -> C {
return { x in f(g(x)) }
}
extension ParameterEncoding {
@nazywamsiepawel
nazywamsiepawel / UINavigationBarWithSubtitle.swift
Last active July 20, 2023 11:58
UINavigationBar with subtitle / swift
func setTitle(title:String, subtitle:String) -> UIView {
let titleLabel = UILabel(frame: CGRect(x:0, y:-5, width:0, height:0))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.text = title
titleLabel.sizeToFit()
import Foundation
private var AssociatedObjectHandle: UInt8 = 0
extension UINavigationBar {
var height: CGFloat {
get {
if let h = objc_getAssociatedObject(self, &AssociatedObjectHandle) as? CGFloat {
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active November 4, 2024 04:14
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@mgrebenets
mgrebenets / share-schemes.rb
Created June 8, 2015 12:04
Share Xcode Schemes
#!/usr/bin/env ruby
# share_schemes.rb
require 'optparse'
require 'ostruct'
require 'rubygems'
require 'xcodeproj'
require 'colorize'
require 'fileutils'