Skip to content

Instantly share code, notes, and snippets.

View al3xandru's full-sized avatar

Alex Popescu al3xandru

View GitHub Profile
// Check out the where clause of the Generic
// Also the `_`
func anyCommonElements <T, U where T: SequenceType, U: SequenceType, T.Generator.Element: Equatable, T.Generator.Element == U.Generator.Element> (lhs: T, _ rhs: U) -> Bool {
}
// should the function be invoked or is this an error
anyCommonElements(["a", "b", "c"], [1])
@al3xandru
al3xandru / gist:272e0de1d399f6bae3d3
Created June 11, 2014 04:57
Example connectionList.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<connectionList>
<connections>
<name>Cassandra 2.0.7</name>
<hosts>NODE IP</hosts>
<port>9042</port>
<compression>NONE</compression>
<requiresCredentials>false</requiresCredentials>
<ssl>false</ssl>
<storePassword>false</storePassword>
@al3xandru
al3xandru / gist:76d1239bac9bf4fe4729
Created May 24, 2014 19:04
Twitter shorten links
al3xandru $ curl -I -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.76.4 (KHTML, like Gecko) Version/7.0.4 Safari/537.76.4" http://t.co/QgPZfAwK0z
HTTP/1.1 200 OK
cache-control: private,max-age=300
content-length: 0
content-type: text/html; charset=utf-8
date: Sat, 24 May 2014 19:00:20 GMT
expires: Sat, 24 May 2014 19:05:20 GMT
server: tfe
set-cookie: muc=acc5d3c2-431f-4f4d-84ba-7e48d3c7edbd;Domain=t.co;Expires=Thu, 05-May-2016 19:00:20 GMT
x-xss-protection: 1; mode=block
@al3xandru
al3xandru / MyClient.java
Created March 26, 2014 03:52
A very basic example of connecting to a Cassandra node using DataStax Java Driver
package com.example.cstar;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
public class MyClient {
public MyClient() {
}
@al3xandru
al3xandru / CqlLexer.py
Last active August 29, 2015 13:57
A Pygments lexer for Cassandra Query Language (CQL)
class CqlLexer(RegexLexer):
"""
Lexer for Cassandra Query Language.
Spec available `here<https://cassandra.apache.org/doc/cql3/CQL.html>`_.
"""
name = 'CQL'
aliases = ['cql']
filenames = ['*.cql']
mimetypes = ['text/x-sql']
# sample output for 5742
# feel free to give more sensible / interesting names to KSs and CFs ordering is based on time of creation of the KS/CF.
lyubent:bin lyubentodorov$ ./nodetool listsnapshots
Snapshot Details:
Snapshot name Keyspace name Column family name True size Size on disk
1393952912539 europe resources 3.44 MB 3.46 MB
1393952912539 europe countries 0 bytes 16.86 MB
1393952912539 asia countries 0 bytes 16.41 MB
1393952912539 northamerica countries 0 bytes 16.17 MB
# Single-line version:
(?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()
@al3xandru
al3xandru / gist:7283595
Last active December 27, 2015 06:39
Ricon West 2013 : Full day streams jump list
## Day 1 - Track 1 ##
00:10:00 Pat Helland: Keystone - Between a ROC and a SOFT place
01:12:18 Lindsey Kuper: LVars: Lattice-based Data Structures for Deterministic Parallelism
02:11:54 Eric Redmond: Yokozuna!
04:10:50 Justin Shoffstall & Charlie Voiselle: The Seven-Layer Burrito; Troubleshooting a Distributed Database in Production
05:11:00 Peter Bailis: Bad as I wanna be - Coordination and Consistency in Distributed Databases
06:13:24 Joseph Blomstedt: Bringing Consistency to Riak (Part 2)
07:16:22 Lightning talks (_nb_: you **must** see @tsantero!)
@al3xandru
al3xandru / ccmtail
Created October 5, 2013 07:31
Bring together the logs from ccm nodes. Run: ccmtail ~/.ccm/cluster_name/ *Note*: make sure that you include the last /
#!/bin/bash
function killtails {
echo ""
echo "Cleaning up..."
for pid in $(ps ax | grep "tail -f ${cluster_dir}/node" | grep -v grep | awk '{print $1}')
do
echo "Killing pid: ${pid}"
kill ${pid}
done
rm -vf "${cluster_dir}/system.log"
javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading&hellip;</strong>";p.id="loadingp";p.style.padding="20px";p.style.background="#fff";p.style.left="20px";p.style.top=0;p.style.position="fixed";p.style.zIndex="9999999";p.style.opacity=".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src="https://gist.github.com/al3xandru/6145492/raw/Bullseye.js?x="+(Math.random());})();