Skip to content

Instantly share code, notes, and snippets.

jaysonsantos /
Last active January 13, 2023 15:33
rust ring example
extern crate ring;
use ring::aead::*;
use ring::pbkdf2::*;
use ring::rand::SystemRandom;
fn main() {
// The password will be used to generate a key
let password = b"nice password";
enriched / jsonSchemaInterface.ts
Last active June 21, 2019 14:06
TypeScript interface for Json-Schema V4
View jsonSchemaInterface.ts
* MIT License
* Copyright (c) 2016 Richard Adams (
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
bjorndown /
Created February 28, 2016 13:20
Rust: Implement fmt::Display for enum
use std::fmt;
enum CellState { Dead, Alive }
impl fmt::Display for CellState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let printable = match *self {
CellState::Alive => 'x',
CellState::Dead => ' ',
View A Few Useful Things to Know about Machine

A Few Useful Things to Know about Machine Learning

The paper presents some key lessons and "folk wisdom" that machine learning researchers and practitioners have learnt from experience and which are hard to find in textbooks.

1. Learning = Representation + Evaluation + Optimization

All machine learning algorithms have three components:

  • Representation for a learner is the set if classifiers/functions that can be possibly learnt. This set is called hypothesis space. If a function is not in hypothesis space, it can not be learnt.
  • Evaluation function tells how good the machine learning model is.
  • Optimisation is the method to search for the most optimal learning model.
beci / gcc 5 on ubuntu 14.04
Created October 15, 2015 07:18
use gcc 5.x on ubuntu 14.04
View gcc 5 on ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
code0100fun / app_controllers_sign-in.js
Created June 8, 2015 20:02
Ember Simple AUth + Ember CLI Mirage
View app_controllers_sign-in.js
// app/controllers/sign-in.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
this.set('errors', null);
var params = { identification: this.get('email'), password: this.get('password') };
// Redirects to index route on success (configurable in config/environment.js)
this.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', params);
samselikoff /
Last active September 13, 2021 09:18
Future-proofing your Ember 1.x code

This post is also on my blog, since Gist doesn't support @ notifications.

Components are taking center stage in Ember 2.0. Here are some things you can do today to make the transition as smooth as possible:

  • Use Ember CLI
  • In general, replace views + controllers with components
  • Only use controllers at the top-level for receiving data from the route, and use Ember.Controller instead of Ember.ArrayController or Ember.ObjectController
  • Fetch data in your route, and set it as normal properties on your top-level controller. Export an Ember.Controller, otherwise a proxy will be generated. You can use Ember.RSVP.hash to simulate setting normal props on your controller.
staltz /
Last active March 31, 2023 03:35
The introduction to Reactive Programming you've been missing
View ember-cli-broccoli-compass.js
app.registry.add('css', 'broccoli-compass', 'scss', {
toTree: function(tree, inputPath, outputPath, options) {
// broccoli-compass doesn't like leading slashes
if (inputPath[0] === '/') { inputPath = inputPath.slice(1); }
tree = mergeTrees([
], {
description: 'TreeMerger (stylesAndVendorAndPublic)'
domderen /
Last active April 17, 2022 06:28
Installation of apache spark on ubuntu machine.
# installation of Oracle Java JDK.
sudo apt-get -y update
sudo apt-get -y install python-software-properties
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get -y update
sudo apt-get -y install oracle-java7-installer
# Installation of commonly used python scipy tools