Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
# https://gist.github.com/4948295
# GistID: 4948295
#
# prereq:
# apt-get install build-essential clang gobjc libicu-dev libxml2-dev libgnutls-dev libssl-dev
#
# Based on: http://www.dev-smart.com/archives/401
# Install:
# clang (Low-Level Virtual Machine (LLVM), C language family frontend)
@DamnedFacts
DamnedFacts / VTPG_Common.h
Last active December 14, 2015 07:19
"The Most Useful Objective-C Code I’ve Ever Written" Reference: http://vgable.com/blog/2010/08/19/the-most-useful-objective-c-code-ive-ever-written/#Get_LOG_EXPR Easy printing of Obj-C type values
#pragma once
// Copyright (c) 2008-2010, Vincent Gable.
// vincent.gable@gmail.com
//based off of http://www.dribin.org/dave/blog/archives/2008/09/22/convert_to_nsstring/
NSString * VTPG_DDToStringFromTypeAndValue(const char * typeCode, void * value);
// WARNING: if NO_LOG_MACROS is #define-ed, than THE ARGUMENT WILL NOT BE EVALUATED
#ifndef NO_LOG_MACROS
@DamnedFacts
DamnedFacts / resolver.py
Last active November 17, 2022 02:36
Forward and Reverse DNS lookups with Python
import sys
"""
Resolve the DNS/IP address of a given domain
data returned is in the format:
(name, aliaslist, addresslist)
@filename resolveDNS.py
@version 1.01 (python ver 2.7.3)
@author LoanWolffe
"""
-- Uses cleaner syntax than common solutions for toggling the state of the Notification Center in Mac OS X Mountain Lion (10.8)
set notificationStatus to do shell script "defaults -currentHost read com.apple.notificationcenterui doNotDisturb"
if notificationStatus is equal to "1" then
do shell script "defaults -currentHost write com.apple.notificationcenterui doNotDisturb -boolean false"
do shell script "defaults -currentHost delete com.apple.notificationcenterui doNotDisturbDate"
do shell script "launchctl stop com.apple.notificationcenterui.agent"
else
do shell script "defaults -currentHost write com.apple.notificationcenterui doNotDisturb -boolean true"
@DamnedFacts
DamnedFacts / gist:5186759
Created March 18, 2013 12:13
BASH: For Loop File Names With Spaces
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for f in *
do
echo "$f"
done
IFS=$SAVEIFS
@DamnedFacts
DamnedFacts / gist:5186794
Created March 18, 2013 12:21
F-Script: Assign pointer address as an object reference in the console
ptr := FSPointer objectPointer
scanner := NSScanner scannerWithString:'0x234243242'
scanner scanHexLongLong:ptr
object := ptr at:0
@DamnedFacts
DamnedFacts / fake-uname.c
Last active September 29, 2020 04:18
Fake uname information in order to make tools, such as megacli, work: Gentoo-11 tmp # gcc -Wall -fPIC -c fake-uname.c Gentoo-11 tmp # gcc -Wall -shared -o libfake-uname.so fake-uname.o Now we get libfake-uname.so, use LD_PRELOAD=./libfake-uname.so to preload it, over uname from glibc: Gentoo-11 tmp # LD_PRELOAD=./libfake-uname.so LD_LIBRARY_PATH…
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <string.h>
int uname(struct utsname *buf)
@DamnedFacts
DamnedFacts / gist:5540735
Created May 8, 2013 14:16
Google Spreadsheet and GData API example
#!/usr/bin/python
#
# Copyright (C) 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@DamnedFacts
DamnedFacts / gist:5540752
Created May 8, 2013 14:18
Internal VirtualBox commands that assist in installing OS X under VirtualBox
# https://www.virtualbox.org/manual/ch03.html
VBoxManage setextradata "Mountain Lion Cage" VBoxInternal2/EfiGopMode 3
VBoxManage modifyvm "Mountain Lion Cage" --firmware efi
VBoxManage setextradata "Mountain Lion Cage" VBoxInternal2/SmcDeviceKey "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
# https://www.virtualbox.org/manual/ch14.html
VBoxManage setextradata "Mountain Lion Cage" "VBoxInternal2/EfiBootArgs" "-v"