Skip to content

Instantly share code, notes, and snippets.

View geon's full-sized avatar

Victor Widell geon

View GitHub Profile
@geon
geon / ellipsis.htm
Created November 20, 2010 21:07
Textshortening and ellipsis with only CSS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Textshortening and ellipsis with only CSS</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
p {
width: 220px;
line-height: 18px;
@geon
geon / app_model.php
Created September 2, 2011 16:51
Get actual integers from MySQL with CakePHP.
<?php
class AppModel extends Model {
function afterFind($results){
if(!isset($results[0])){
// $results is a single object.
$results = $this->realAfterFind($results);
<?php
$content = '
Text with newlines, possible XSS attacks and URLs.
<script type="text/javascript">alert("this could be an XSS attack.");</script>
The URL to my github page is https://github.com/geon.
';
@geon
geon / backbone.local-buffered.js
Created December 10, 2013 13:05
Experimenting with a LocalStorage buffer for backbone in case of dropped connection.
"use strict";
var LocalBuffered = {};
LocalBuffered.Model = Backbone.Model.extend({
constructor: function () {
Backbone.Model.apply(this, arguments);
@geon
geon / demo.sh
Created October 1, 2015 06:09
Command line tool to extract values from a JSON file.
echo '{"foo1":123, "foo":{"bar":[1,2,3]}}' | ./json.js foo.bar.2
@geon
geon / gist:e8b9e1125325e39c58b9
Created October 5, 2015 09:28
PipelineDB example
Data:
{"type":"add","uuid":"4b24edb2-5074-4a3a-95cb-927d5535da7c","topic":"clients","data":{"time":"2015-03-23T15:45:34.995Z"}}
{"type":"add","uuid":"26ff7bdb-9913-47ab-a6df-8c985320c1bb","topic":"clients","data":{"time":"2015-03-23T15:45:36.082Z"}}
{"type":"add","uuid":"914096b8-dc66-4239-bb1c-88baba0c1831","topic":"lines","data":{"time":"2015-03-23T15:45:40.323Z","clientId":"26ff7bdb-9913-47ab-a6df-8c985320c1bb","line":"Hello?"}}
{"type":"add","uuid":"bdb60b1e-b34b-490e-a737-0ceb81208f4e","topic":"lines","data":{"time":"2015-03-23T15:45:44.935Z","clientId":"4b24edb2-5074-4a3a-95cb-927d5535da7c","line":"What?"}}
{"type":"del","uuid":"4b24edb2-5074-4a3a-95cb-927d5535da7c","topic":"clients"}
{"type":"add","uuid":"f9aacc7e-1745-4a54-8e54-b9bea3cbc3bb","topic":"clients","data":{"time":"2015-03-23T15:45:59.800Z"}}
{"type":"add","uuid":"2c45cca3-cfa5-4ac2-bfec-12ca985d869b","topic":"lines","data":{"time":"2015-03-23T15:46:15.624Z","clientId":"f9aacc7e-1745-4a54-8e54-b9bea3cbc3bb","line":"Works finw"}}
{"type":"ad
@geon
geon / index.jade
Created February 5, 2016 21:46
Flexbox full-page web app layout with scrollable panels.
.full-screen.column
.header Header
.main.stretchy
.left Menu-stuff here
ul
li Menu Entry
li Menu Entry
li Menu Entry
li Menu Entry
li Menu Entry
@geon
geon / keyof.ts
Created December 8, 2016 12:13
Typed Backbone-style models with `keyof` in Typescript 2.1
class Model<T> {
props: T;
constructor(initial: T | void){
if (initial) {
this.props = initial;
}
}
set<K extends keyof T>(propName: K, value: T[K]) {
this.props[propName] = value;
@geon
geon / demo.sql
Created June 1, 2017 12:37
pipelinedb event clustering
-- DROP SCHEMA public CASCADE;
-- CREATE SCHEMA public;
-- The bad measurements that should be clustered into errors.
CREATE STREAM bad_measurements ("measurement" REAL, "timestamp" TIMESTAMPTZ);
-- This is only useful because it create an output stream of deltas, important for clustering events.
@geon
geon / tsbug.ts
Last active November 20, 2017 14:50
console.log(myFunction());
const myConstant = "";
function myFunction(myArgument: string = myConstant): string {
return myArgument;
}