Skip to content

Instantly share code, notes, and snippets.

View jdee's full-sized avatar
🏳️‍🌈

Jimmy Dee jdee

🏳️‍🌈
View GitHub Profile
@jdee
jdee / knob-control-and-violation.md
Last active August 29, 2015 14:03
iOS Knob Control and Violation

The iOS Knob Control and a new project, a framework for iOS called Violation, were both spun out of other large app projects I've been working on. The knob control came first. It resides in its own repo, has an unimaginative name that invites conflicts and is distributed simply as a single .h and .m file pair you can insert into your project.

That effort went well enough, and I was inspired to release some further custom iOS components from the same project. But the way the knob control was released would not scale to many classes, particularly with the introduction of things like base classes and private extensions.

Clearly all these things ought to share a single repo and be collected into a framework or other sort of

@jdee
jdee / gist:8ffe94322de97dcb6dc4
Created July 21, 2014 19:05
evolution of computing languages
// C (1972):
// for (char letter='A'; letter <= 'Z'; ++ letter) {
// Ruby (1995):
// [A..Z].each { |letter|
// drum roll, please
// Swift (2014):
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // Hope I didn't mistype that. And never accidentally modify it.
@jdee
jdee / gist:e81170da4f86dbbc61cd
Last active August 29, 2015 14:04
failing script without rvm use default
# From: http://beginrescueend.com/workflow/scripting/
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
@jdee
jdee / gist:e1b877ec0fb34b3c2723
Last active August 29, 2015 14:11
Obama's first script
function findSnowden() {
var latitude=-90.0, longitude=-180.0;
var delta=1e-5;
var found=false;
// TODO: Speed up this part
while (!found && latitude <= 90.0 && longitude <= 180.0) {
var squareMeter = Russia.getRegion(latitude, longitude, 1.0, 1.0);
if (squareMeter) {
var results = squareMeter.find(function(person) {
@jdee
jdee / ops.cpp
Created April 12, 2016 23:53
Hello, Operator
int i = 0;
++ ++ i; // no problem
i ++ ++; // doesn't compile
/*
* It has to do with how these operators work and in particular their return types. The prefix operator returns
* the value after modification. The postfix operator returns the value before modification. But how does it do
* that? These operators date back to C at least. It's not some background task that happens after the operator
* finishes. The prefix operator returns a reference to the same thing (int, object, etc.). The postfix operator
* returns a temporary value. It stores the value in a separate location, modifies the value at the original
@jdee
jdee / Fastfile
Last active November 16, 2017 20:19
Shell escapes in a Fastfile
url = "https://www.google.com"
content_type = "content-type: application/json"
data = %q({"title": "What's New"})
output = sh "curl -X POST #{url.shellescape} -H #{content_type.shellescape} -d #{data.shellescape}"
@jdee
jdee / Fastfile.swift
Last active December 18, 2017 18:17
settings API for Fastfile.swift
settings().minFastlaneVersion = "2.69.3"
settings().teamId = "ABCDEFG"
settings().myPlugin().pluginSetting = true
settings {
s in
s.minFastlaneVersion = "2.69.3"
s.teamId = "ABCDEFG"
s.myPlugin {
p in
@jdee
jdee / buffer.cpp
Last active June 4, 2019 18:17
buffer allocation
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
#undef BAD
void funcWithNullTerminatedArray(const char* buffer)
{
cout << buffer << endl;
@jdee
jdee / consttest.cpp
Last active June 13, 2019 19:44
Const and reference members
#include <iostream>
#include <string>
using namespace std;
class MyThing
{
public:
/*
* Have to override default constructor to initialize const and reference members.
@jdee
jdee / constexprtest.cpp
Last active June 21, 2019 17:31
constexpr (C++11)
#include <iostream>
#include <string>
using namespace std;
struct ConstexprTest
{
static bool const s_bool = true ;
static int const s_int = 42 ;