Skip to content

Instantly share code, notes, and snippets.

View l0gicpath's full-sized avatar

Hady Mahmoud l0gicpath

View GitHub Profile
@kmizu
kmizu / parsers.nim
Created July 1, 2016 00:51
parser combinator library in Nim
import strutils
import lists
import re
type
Parser[T] = proc(input: string): Maybe[(T, string)]
Maybe*[T] = object
value: T
hasValue: bool
@nathan-osman
nathan-osman / win32.go
Last active July 18, 2024 16:55
Simple Windows GUI application written in Go
package main
import (
"log"
"syscall"
"unsafe"
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")

Creating a redis Module in 15 lines of code!

A quick guide to write a very very simple "ECHO" style module to redis and load it. It's not really useful of course, but the idea is to illustrate how little boilerplate it takes.

Step 1: open your favorite editor and write/paste the following code in a file called module.c

#include "redismodule.h"
/* ECHO <string> - Echo back a string sent from the client */
int EchoCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
@eddieh
eddieh / libevent-v-libuv.md
Last active March 7, 2024 20:33
libevent vs libuv

libevent vs libuv

Comparing libevent and libuv. My upfront biased: I want to like libevent. However, I want to objectively compare the two and make an informed decision.

What versions are we comparing?

  • libevent 2.0.22 (Stable) [2014-01-05]
  • libuv 1.8.0 (Stable) [2015-12-15]
@JeffreyWay
JeffreyWay / routes.php
Last active August 18, 2019 00:06
This route will require authentication with a valid api_token, and then return the relevant user, as JSON. - https://laracasts.com/series/whats-new-in-laravel-5-2/episodes/5
<?php
Route::group([
'prefix' => 'api/v1',
'middleware' => ['api', 'auth:api']
], function () {
Route::get('/', function () {
return Auth::guard('api')->user();
});
@mpfund
mpfund / fileupload.go
Created February 29, 2016 07:39
golang file upload
package main
import (
"bytes"
"fmt"
"io/ioutil"
"mime/multipart"
"net/http"
)
@ahmedelgabri
ahmedelgabri / getType.js
Created January 8, 2016 12:50
Simple check for the type of an object
function getType(target){
return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
}
@benlinton
benlinton / multiple_mysql_versions_for_development.md
Last active September 23, 2023 09:38
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions for Development

Options included below:

  • Using Docker docker-compose
  • Using Homebrew brew

Using Docker (recommended)

This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer. Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.

@Janther
Janther / logo_codility.rb
Last active June 25, 2018 20:20
Codility Task LOGO turtle - SegmentCrossing
def intersects?(p0, p1, p2, p3)
s1_x = p1[0] - p0[0]
s1_y = p1[1] - p0[1]
s2_x = p3[0] - p2[0]
s2_y = p3[1] - p2[1]
denom = s1_x * s2_y - s2_x * s1_y
# if denom == 0 lines are parallel
# TODO: aditional check if they overlap
return false if (denom == 0)

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).