Skip to content

Instantly share code, notes, and snippets.

View hankbao's full-sized avatar
🧠
use it or lose it

Hank Bao hankbao

🧠
use it or lose it
  • Vancouver, BC
  • 05:06 (UTC -07:00)
  • X @hankbao
View GitHub Profile
@tijme
tijme / UITextViewPlaceholder.swift
Last active February 18, 2025 18:47
The correct way to implement a placeholder in a UITextView (Swift)
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Copyright (c) 2017 Tijme Gommers <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
import Cocoa
//typealias Parser<Token, A> = (Tokens) -> (A, Tokens)?
struct Parser<Tokens, A> {
let parse: (Tokens) -> (A, Tokens)?
}
typealias Stream<A> = Parser<String.CharacterView, A>
# You can download this config from: http://surge.run/config-example/ios.conf
# Edit with your computer and copy back to iOS device via iTunes, URL, AirDrop
# or iCloud Drive
# Version 2.0
[General]
# Log level: warning, notify, info, verbose (Default: notify)
loglevel = notify
# Skip domain or IP range. These hosts will not be processed by Surge Proxy.
# (In macOS version when Set as System Proxy enabled, these hosts will be
@fffaraz
fffaraz / dns.c
Created May 29, 2016 05:58
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon ([email protected])
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
//
// Created by Eric Firestone on 3/22/16.
// Copyright © 2016 Square, Inc. All rights reserved.
// Released under the Apache v2 License.
//
// Adapted from https://gist.github.com/blakemerryman/76312e1cbf8aec248167
import Foundation
@kornelski
kornelski / sparklecheck.sh
Created February 14, 2016 00:44
Find apps with unsafe Sparkle versions
#!/bin/bash
set -o pipefail
IFS=$'\n'
REPORT=''
checkapp() {
local APPPATH=$1
local PLIST="$APPPATH/Contents/Info.plist"
local SPARKLEPLIST="$APPPATH/Contents/Frameworks/Sparkle.framework/Resources/Info.plist"
local SPARKLEBIN="$APPPATH/Contents/Frameworks/Sparkle.framework/Sparkle"
@bkaradzic
bkaradzic / orthodoxc++.md
Last active April 4, 2025 07:46
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

import Glibc
// Swift 3 version here: https://gist.github.com/erica/7aee99db9753a1636e0fbed8d68b5845
/*
Did a bunch of tweaks this morning:
removed == true (sorry Kametrixom!)
cleaned up both stringFromBytes and bytesFromString
changed fperror check to guard
replaced use of 1024 in several places with a single constant
import Cocoa
// for-in
func checkForIn(array: [Int], dict: [Int: String]) {
for num in array where dict[num] != nil {
num
}
}
checkForIn([1,2,3,4], dict: [1:"one", 2:"two"])