Skip to content

Instantly share code, notes, and snippets.

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

Jimmy Dee jdee

🏳️‍🌈
View GitHub Profile
@jdee
jdee / updater.cpp
Last active June 28, 2019 17:34
passing a writable method
#include <exception>
#include <iostream>
#include <string>
using namespace std;
struct GetterOfThings
{
virtual ~GetterOfThings() {}
@jdee
jdee / pocomutex.cpp
Created June 21, 2019 17:41
Poco mutexes and scoped locks
#include <Poco/Mutex.h>
using namespace Poco;
class MyClass {
public:
bool getData() const {
Mutex::ScopedLock _l(_mutex);
return _data;
}
@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 ;
@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 / 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 / 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 / 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 / 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 / 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 / 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