Skip to content

Instantly share code, notes, and snippets.

View lucperkins's full-sized avatar
🎯
Focusing

Luc Perkins lucperkins

🎯
Focusing
View GitHub Profile
@lucperkins
lucperkins / objectMerge.js
Last active December 29, 2015 14:29
Is this really the only way to do this???
var object1 = { firstName: 'Luc', lastName: 'Perkins' };
var object2 = { age: 31, hobbies: ['singing', 'guitar', 'history', 'philosophy', 'programming']};
for (key in object2) {
object1[key] = object2[key];
}
// The result
{ firstName: 'Luc',
lastName: 'Perkins',
@lucperkins
lucperkins / compatible_json.dart
Last active December 30, 2015 20:19
I was looking for a good way to make sure that an object is properly constructed on the basis of a `fromJson` method. The only way to ensure this is to first ensure that the JSON object from which the object is being constructed has the same keys as required by the object's class. I've chosen to do this by constructing an abstract `CompatibleWit…
import 'dart:convert';
abstract class CompatibleJson {
Map<String, dynamic> get attributes;
bool jsonCompatible(Map<String, dynamic> json) {
return (json.keys.length == attributes.keys.length) &&
(json.keys.every((String key) => key.runtimeType == String)) &&
(json.keys.every((String key) => attributes.keys.contains(key)) &&
(json.values.every((dynamic value) => attributes.values.runtimeType == value.runtimeType));
@lucperkins
lucperkins / hegel.dart
Created December 9, 2013 21:15
Some Hegel-flavored musings. In #dartlang, of course.
abstract class Being {}
abstract class Nothing {}
abstract class Becoming extends Being with Nothing {}
abstract class Nature extends Becoming {}
abstract class Lack extends Nature {}
abstract class LivingThing extends Lack {}
class Person extends LivingThing {
String name;
Person(this.name);
@lucperkins
lucperkins / floatingMenu.css
Last active December 30, 2015 20:59
Here's a Gist for HTML/CSS/JS for a menu bar that is both draggable and resizable AND stores the height/width and position of the bar in local storage, so that the dimensions and position persist through refresh. There is a <p> element inside of the floating bar that is the only element that can be clicked on to drag the bar. This can be disable…
#floatingMenu {
border: 1px solid black;
}
@lucperkins
lucperkins / components.dart
Created January 27, 2014 03:06
Making data types iterable in Dart
@CustomTag('x-note-element')
class NoteElement extends LIElement with Polymer, Observable {
@published Note note;
NoteElement.created() : super.created();
}
@CustomTag('x-notebook-element')
class NotebookElement extends PolymerElement {
@published Notebook notebook = new Notebook(new List<Note>());
NotebookElement.created() : super.created();
@lucperkins
lucperkins / riak_security.md
Last active August 16, 2016 06:09
Blog article on Riak 2.0 security

Riak Security 2.0: Not Just a Firewall Anymore

If you wanted to use Riak in a secure fashion in versions prior to 2.0, your only option was to do so at the network level, using a firewall or similar protective layer. While this is sufficient for a lot of use cases, the problem with this form of security is that if someone can penetrate the firewall, they essentially have unrestricted access to a Riak cluster. They can perform reads and writes, run MapReduce jobs, you name it.

In Riak version 2.0, this is changing in dramatic fashion. While you can still apply a network security layer if you wish, Riak now comes with security features that protect Riak itself and not just to the network in which it's housed. Most importantly, in Riak 2.0 you can both authorize users to perform specific tasks (from standard read/write/delete operations to search queries to managing bucket types) and authenticate users and clients using a variety of security mechanisms.

I

Here is the master list of all currently available `riak.conf` params:
### Homeless
retry_put_coordinator_failure
metadata_cache_size
### Search
search.root_dir

Proposed new docs

Topic Y or N Assignee
Rolling restart
package basho.riak;
import com.basho.riak.client.RiakClient;
import com.basho.riak.client.operations.FetchDatatype;
import com.basho.riak.client.operations.FetchSet;
import com.basho.riak.client.operations.UpdateSet;
import com.basho.riak.client.operations.datatypes.SetUpdate;
import com.basho.riak.client.operations.indexes.BinIndexQuery;
import com.basho.riak.client.operations.kv.DeleteValue;
import com.basho.riak.client.operations.kv.FetchValue;
@lucperkins
lucperkins / migration.py
Last active November 7, 2016 11:15
Migrate SQL table to Riak
import psycopg2
from riak import RiakClient, RiakObject
from riak.datatypes import Set
import datetime
# Riak connection and set
client = RiakClient(pb_port=8087)
SETS_BUCKET = client.bucket_type('sets').bucket('key_sets')
# Get columns for table