Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza NourelahiAlamdari mortymacs

View GitHub Profile
@etozzato
etozzato / acl.coffee
Last active May 31, 2016 15:20
ACL in EmberJS
FakeApp.Admin.ACL = Ember.Mixin.create
# How to USE ACL
# pass the mixin as first parameter of the route extend method and
# define the roles that are allowed
#
# ApplicationRoute = Ember.Route.extend FakeApp.Admin.ACL,
# roles: ['superuser', 'recruiter']
beforeModel: (transition) ->
return if 'unauthorized' == transition.targetName
@_super()
@ctokheim
ctokheim / cython_tricks.md
Last active March 4, 2024 23:27
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.

@betrcode
betrcode / README.md
Created June 24, 2014 06:36
Using Python to check if remote port is open and accessible.
@michaljemala
michaljemala / tls-client.go
Last active May 9, 2025 13:18
SSL Client Authentication Golang sample
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
/* Based on Sublime Text's Monokai theme */
.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2;}
.cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
.cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
.cm-s-monokai .CodeMirror-linenumber {color: #d0d0d0;}
.cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
.cm-s-monokai span.cm-comment {color: #75715e;}
.cm-s-monokai span.cm-atom {color: #ae81ff;}
@mitchwongho
mitchwongho / Docker
Last active April 16, 2025 07:28
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@mortymacs
mortymacs / size.c
Created April 24, 2014 15:21
convert number to human-readable size in C
#include <stdio.h>
char *types[] = {"KB","MB","GB","TB","PB","EB","ZB","YB"};
void change(int *size)
{
int div = 1024;
int i = 0;
for(;i<8;i++)
{
*size /= div;
if(*size < div)
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 25, 2025 20:12
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@oderwat
oderwat / gist:9158840
Created February 22, 2014 17:45
GoLang HTTP PUT / DELETE (just copied from somewhere else!)
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
const (
@denji
denji / http-benchmark.md
Last active May 15, 2025 12:21
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)