Skip to content

Instantly share code, notes, and snippets.

View vaidd4's full-sized avatar

David vaidd4

  • France
View GitHub Profile
@dz4k
dz4k / Draggable._hs
Last active December 25, 2023 10:47
Draggable window in _hyperscript
-- Usage: _="install Draggable(dragHandle: .titlebar in me)"
behavior Draggable(dragHandle)
init
if no dragHandle set the dragHandle to me
end
on pointerdown(clientX, clientY) from dragHandle
halt the event
trigger draggable:start -- hooks, e.g. for adding a drop shadow while dragging
measure my x, y
@Spiikesan
Spiikesan / SleepSort.go
Last active April 16, 2019 21:58
Sort algorithm with no condition in golang.
package main
import (
"fmt"
"time"
)
func sleepSort(tab []int) ([]int) {
out := make([]int, len(tab))
waiter := make(chan int, len(tab))
@dsalahutdinov
dsalahutdinov / Dockerfile.dev
Last active May 25, 2021 21:02
Dockerize Ruby backend of the multi-service application for local development
FROM ruby:2.6.1
ARG PG_VERSION
ARG NODE_VERSION
ARG TINI_VERSION=v0.18.0
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' $PG_VERSION > /etc/apt/sources.list.d/pgdg.list \
&& curl -o /tmp/nodejs.deb https://deb.nodesource.com/node_11.x/pool/main/n/nodejs/nodejs_$NODE_VERSION-1nodesource1_amd64.deb \
&& apt-get update -qq \
@jochemstoel
jochemstoel / native jQuery methods.js
Last active November 9, 2023 15:53
Vanilla implementations of commonly used jQuery methods.
/**
* Convenient shortcut
*/
Object.defineProperty(window, 'define', {
value: (property, ...meta) => meta.length == 2 ? Object.defineProperty(meta[0], property, meta[1]) : Object.defineProperty(window, property, meta[0]),
writable: false,
enumerable: true
})
@lummie
lummie / enum.go
Last active November 4, 2023 18:09
Golang Enum pattern that can be serialized to json
package enum_example
import (
"bytes"
"encoding/json"
)
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred
type TaskState int
@andyshinn
andyshinn / Dockerfile
Created December 24, 2015 19:07
BusyBox cron container example
FROM gliderlabs/alpine:3.3
COPY myawesomescript /bin/myawesomescript
COPY root /var/spool/cron/crontabs/root
RUN chmod +x /bin/myawesomescript
CMD crond -l 2 -f
@emertechie
emertechie / gist:197c87d345500b7cdbba
Last active June 18, 2018 00:36
Using Cordova/PhoneGap Facebook SDK in an Ionic App
var module = angular.module('facebook', []);
module.constant('facebookInit', function(facebookAppID) {
var initialized = false;
return function($q) {
if (initialized) {
return;
@tristanwietsma
tristanwietsma / auth.go
Created May 15, 2014 04:15
Golang web server example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@ryanflorence
ryanflorence / static_server.js
Last active March 13, 2024 08:05
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);