Skip to content

Instantly share code, notes, and snippets.

@pekhee
pekhee / DepFile
Last active March 27, 2017 20:06
Potential syntax for rish
DEPS: libsmt, smt
COMPILE:"""
# Input LIBSMT_PATH, SMT_PATH
compile
"""
KEEP:"""
# Input KEEP_PATH
cp * $KEEP_PATH
"""
EXPOSE:"""
@pekhee
pekhee / monad_transformer.hs
Last active November 1, 2016 11:09
To do an IO action with the resulting value of a Monad we can either unwrap the Monad or use a Monad Transformer
import Control.Monad.Trans (lift)
import Control.Monad.Trans.Maybe (MaybeT, runMaybeT)
monadicAdd :: Monad m => m Int -> m Int -> m Int
monadicAdd l r = do
l_ <- l
r_ <- r
return (l_ + r_)
printWithTransformerMonad :: MaybeT IO Int -> MaybeT IO Int
@pekhee
pekhee / test.rb
Created August 2, 2016 13:06
Ruby blocks close their instance/class variable targets regardless of binding they are evaluated in.
class Foo
@@foo = :foo
end
class Example
@@foo = :example
Foo.define_singleton_method :foo do
@@foo
end
@pekhee
pekhee / text.md
Created June 11, 2014 03:13
Getting Custom Routes, or Nested Routes to Work in Ember Data.

Say a User has many Posts.

App.User = DS.Model.extend({
  posts: DS.hasMany('post', {async: true})
});


App.Post = DS.Model.extend({
 user: DS.belongsTo('user', {async: true})
@pekhee
pekhee / connection.php
Created April 5, 2014 23:56
Setup database connection for Eloquent outside of Laravel.
<?php // Namespace DB;
use Illuminate\Database\Capsule\Manager as Capsule;
class Connection {
public function __construct()
{
$this->capsule = new Capsule;
// Same as database configuration file of Laravel.
@pekhee
pekhee / push.php
Last active August 31, 2016 16:11
Automates pushing to remotes using Git as version control. Adds every new file, Commit everything with user supplied message or a default message if user is not specified one. Also all commits are signed with "-s" option. In case user does not specify a remote, it will push master to every remote. Usage: push "My commit message" "My remote name"…
#!/usr/bin/env php
<?php
$default_message = "A minor change to code, in order to test it."; // Your default message goes here!<<<<<<<<<<<<<<<<<<<<<
// HELP
if( array_get($argv, 1) == 'help' || array_get($argv, 1) == '-h' || array_get($argv, 1) == '--help'){
echo PHP_EOL;
echo "************************************" . PHP_EOL;
@pekhee
pekhee / array_sample_usage.cpp
Last active October 30, 2019 21:11 — forked from saman021/gist:5513829
Sample array usage in C++
// Dependencies:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
int main(){
// Init program
clrscr();
// Vars: