Skip to content

Instantly share code, notes, and snippets.

@lesterzone
lesterzone / ruby_inheritance.rb
Created October 18, 2023 01:44 — forked from yoelblum/ruby_inheritance.rb
Ruby base class VS including modules (mixins)
# Ruby's inheritance mechanisms are a bit unique and have some subtelties
# There are two main ways to inherit: Direct Inheritance (with a "Base" class) and "Mixins" (including modules)
# "Direct inheritance" (B is the base class of A)
class B
X = 30
def self.static_method
"Hello from static method"
end
@lesterzone
lesterzone / scratch.rb
Created August 12, 2022 15:52 — forked from mateuszbialowas/scratch.rb
ar-mapping-custom-pk-fk
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pry'
gem "sqlite3"
gem 'activerecord'
end
@lesterzone
lesterzone / Makefile
Created October 4, 2021 14:30 — forked from thomaspoignant/Makefile
My ultimate Makefile for Golang Projects
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=example
VERSION?=0.0.0
SERVICE_PORT?=3000
DOCKER_REGISTRY?= #if set it should finished by /
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
GREEN := $(shell tput -Txterm setaf 2)
@lesterzone
lesterzone / customMiddleware.js
Last active October 1, 2017 05:02
Dynamic middleware for Express
/**
* Apply custom middlewares to request
* Usage:
* 1- Identify that you require dynamic middlewares for your endpoint.
* 2- assign each middleware to a variable and push it to an array
* const middlewares = [middleware1, middlware2];
* 3- require this file with expected objects.
*
* Example:
* const middleware1 = require('some middleware file here');
@lesterzone
lesterzone / Capfile
Last active August 29, 2015 14:18
Deploy Ruby on Rails API with Capistrano and RVM
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rvm'
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@lesterzone
lesterzone / package.json
Last active August 29, 2015 14:13
Start working with React.js
{
"name": "update name",
"version": "0.0.1",
"description": "A nice app",
"repository": "",
"author": "your name",
"main": "js/app.js",
"dependencies": {
"backbone": "^1.1.2",
"flux": "^2.0.1",
@lesterzone
lesterzone / audio.css
Last active May 17, 2018 14:55
React.js Html5 audio tag
.audio {
position: relative;
}
.audio > canvas {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
}
.audio-play {
@lesterzone
lesterzone / Jakefile
Created July 30, 2014 03:01
My approach to test GeddyJS(an API application) with Mocha
/**
* Namespace to run some componnents of the API
* @ref http://jebchit.info/pr/browse.php/Oi8vamFr/ZWpzLmNv/bS9kb2Nz/b5/
* @return {Object}
*/
namespace('tests', function() {
var Mocha = require('mocha'),
fs = require('fs'),
mocha, runTests;