Skip to content

Instantly share code, notes, and snippets.

View umurgdk's full-sized avatar

Umur Gedik umurgdk

View GitHub Profile
abstract class Parsec::Parser(T)
getter error_message
def initialize
@is_satisfied = false
@is_failed = false
@cargo = ""
@error_message = ""
end
get "/users/:id{Int32}", do |env, id|
# id here Int32
# if :id couldn't parsed as Int32 an error thrown or 404
puts "#{id + 100}"
end
root@localhost:~/crystal# make
CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
Invalid memory access (signal 11) at address 0x7ff5ffeefab8
[12638893] __crystal_sigfault_handler +61
[24690684] sigfault_handler +40
@umurgdk
umurgdk / Goal.scala
Last active July 26, 2016 16:34
CSV Serializer
object DeepGoal {
implicit val deepGoalCodec = AutomaticJsonCodecBuilder[DeepGoal]
def apply(goal:GoalWithId, prevailingMeasure:Option[MeasureWithId]) = {
new DeepGoal(goal.id.id,
goal.model.status,
goal.model.name,
goal.model.agencies,
goal.model.relatedDatasets,
goal.model.isPublic,
def list() = {
println(s"-------------------Domain ID: $domainId")
val dashboardKeys = for {
row <- session.execute(GET_DASHBOARD_IDS, domainId.toString).all.asScala
dashboardId <- Option(row.getString("dashboardId"))
key = s"$domainId-$dashboardId"
} yield key
println("---------------------Dashboard keys:")
println(dashboardKeys.toList)
CREATE TABLE "Measures" (
key text,
created_at timestamp,
updated_at timestamp,
version = timestamp,
start_date text,
end_date text,
unit text,
target varint,
target_type text,
import requests
instance_url = 'https://mastodon.cloud'
api_base_url = instance_url + '/api/v1'
# final url is https://mastodon.cloud/api/v1/instance
def get_instance_info():
req = requests.get(api_base_url + '/instance')
return req.json()
extern crate rusqlite;
extern crate app_dirs;
extern crate libc;
use rusqlite::{Connection, Statement};
use app_dirs::*;
use std::fs::{File};
use std::io::prelude::*;
use std::sync::mpsc::channel;
use std::sync::mpsc::{Sender, Receiver};
@umurgdk
umurgdk / body_parser.rs
Created June 18, 2017 02:46
Body parser memory leak!
use std::collections::BTreeMap;
use iron::prelude::*;
use iron::{BeforeMiddleware, typemap};
use params::Params;
use serde_json;
use models::Payload;
pub fn remove_child(&mut self, child: &Box<View>) -> Option<Box<View>>
{
match self.children.iter().position(|v| ptr::eq(v, child)) {
Some(index) => Some(self.children.remove(index)),
None => None
}
}