Skip to content

Instantly share code, notes, and snippets.

View jungbin-kim's full-sized avatar

Jungbin Kim jungbin-kim

View GitHub Profile
@brennanMKE
brennanMKE / directoryExistsAtPath.swift
Created April 20, 2017 22:23
Directory Exists at Path in Swift
fileprivate func directoryExistsAtPath(_ path: String) -> Bool {
var isDirectory = ObjCBool(true)
let exists = FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory)
return exists && isDirectory.boolValue
}
@mattlawer
mattlawer / DisableGDB.swift
Created December 25, 2016 17:13
Disable GDB with Swift 3
import Foundation
func disable_gdb() {
let PT_DENY_ATTACH: CInt = 31
let handle = dlopen("/usr/lib/libc.dylib", RTLD_NOW)
let sym = dlsym(handle, "ptrace")
typealias PtraceAlias = @convention(c) (CInt, pid_t, CInt, CInt) -> CInt
let ptrace = unsafeBitCast(sym, to: PtraceAlias.self)
_ = ptrace(PT_DENY_ATTACH, 0, 0, 0)
dlclose(handle)
@LeoAref
LeoAref / dispatcher.js
Last active October 5, 2022 11:04
Simple event dispatcher implementation using JavaScript
export class Dispatcher {
constructor () {
this.events = {};
}
addListener (event, callback) {
// Check if the callback is not a function
if (typeof callback !== 'function') {
console.error(`The listener callback must be a function, the given type is ${typeof callback}`);
return false;
@cdmckay
cdmckay / MultipartFormDataWriteableExample.scala
Created June 24, 2015 05:04
An example of how to use MultipartFormDataWriteable
import play.api.libs.ws.WS
import play.api.mvc.MultipartFormData.FilePart
import play.api.mvc.MultipartFormData
import utilities.MultipartFormDataWriteable._
...
val url = "https://example.com"
val dataParts = Map(
@sureshnath
sureshnath / h2.help.txt
Created April 2, 2013 10:14
sample h2 memory url and sql scripts to load from class path
DB_URL=jdbc:h2:mem:datasource;MODE=Oracle;INIT=runscript from 'classpath:/sql/h2.creation.sql'
h2.creation.sql
-------------------------
runscript from 'classpath:/testing/beforeclass/001-init.sql'; -- from class path
runscript from '~/001-init.sql'; --from ${user.home}