Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Ahmad Karimpour ahmadina

🎯
Focusing
View GitHub Profile
@ahmadina
ahmadina / should_have_attr_accessor.rb
Last active Oct 3, 2017
RSpec attr accessor check
View should_have_attr_accessor.rb
RSpec::Matchers.define :have_attr_accessor do |field|
match do |klass|
klass.respond_to?(field) && klass.respond_to?("#{field}=")
end
failure_message do |klass|
"expected attr_accessor for #{field} on #{klass}"
end
failure_message_when_negated do |klass|
@ahmadina
ahmadina / webcam.rb
Created Sep 28, 2017
using webcam with OpenCV
View webcam.rb
#!/usr/bin/env ruby
require 'opencv'
include OpenCV
FPS = 30
input = CvCapture.open
win = GUI::Window.new 'video'
loop do
View monitorEvents.js
function monitorEvents(element) {
var log = function(e) { console.log(e);};
var events = [];
for(var i in element) {
if(i.startsWith("on")) events.push(i.substr(2));
}
events.forEach(function(eventName) {
element.addEventListener(eventName, log);
});
@ahmadina
ahmadina / gist:69dbcd8114341591b3f48f31bff17777
Created Jul 12, 2016
Stop / Remove all Docker containers
View gist:69dbcd8114341591b3f48f31bff17777
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@ahmadina
ahmadina / pm2.json
Last active Dec 15, 2019
using PM2 for run ES6 (babel) application
View pm2.json
{
"apps": [{
"name": "Application",
"exec_interpreter": "./node_modules/babel-cli/bin/babel-node.js",
"script": "./bin/www",
"args": [],
"watch": ["public", "package.json", "pm2.development.json"],
"ignore_watch": ["public"],
"watch_options": {
"persistent": true,
View gist:7e249cecda1b381c431a
<?php
/**
* Ahmad Karimpour <me@ahmadina.com>
*
* Created_at 2012
*
* Class Enum
*/
class Enum