Skip to content

Instantly share code, notes, and snippets.

View ahaikal's full-sized avatar

ahaikal ahaikal

  • Miami, FL
View GitHub Profile
@ahaikal
ahaikal / touchable.js
Created September 7, 2020 16:18 — forked from LMestre14/touchable.js
React-Native touchable component, Opacity for iOS and NativeFeedback for Android
import React, { Component } from 'react';
import { View, Platform, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback } from 'react-native';
const disabledStyle = { opacity: 0.5 };
let TouchableComponent = TouchableOpacity;
if (Platform.OS === 'android') {
TouchableComponent = Platform.Version <= 20 ? TouchableOpacity : TouchableNativeFeedback;
}
(function ($) {
"use strict";
if (!$.browser) {
$.browser = {};
$.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
$.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
$.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
$.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
$.browser.device = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase());
}
@ahaikal
ahaikal / React Scroll Event
Created May 20, 2018 23:43 — forked from tmocellin/React Scroll Event
Handle the scroll event in react js and change the navbar class when special section is on top of windows
var Hello = React.createClass({
getOffset : function(element){
var bounding = element.getBoundingClientRect();
return {
top: bounding.top + document.body.scrollTop,
left: bounding.left + document.body.scrollLeft
};
},
@ahaikal
ahaikal / clear.txt
Created March 5, 2018 04:14 — forked from EQuimper/clear.txt
React-Native clear Watchman + Cache
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start -- --reset-cache
@ahaikal
ahaikal / db.rake
Created April 21, 2017 22:44 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@ahaikal
ahaikal / lambda-dynamodb-scan
Created April 6, 2017 19:13 — forked from markusklems/lambda-dynamodb-scan
Short aws lambda sample program that scans a dynamodb table
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
@ahaikal
ahaikal / rich_domain_models2.md
Created September 19, 2016 04:58 — forked from vsavkin/rich_domain_models2.md
Building Rich Domain Models in Rails (revision 2)

Building Rich Domain Models in Rails.

Part 1. Decoupling Persistence.

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about in this article.

@ahaikal
ahaikal / interfax_example05.rb
Created June 9, 2016 21:11 — forked from rubiii/interfax_example05.rb
Savon InterFAX example: Chunked upload to fax
# more examples at:
# https://gist.github.com/903337
require "rubygems"
require "base64"
require "date"
# $ gem install savon (works with v0.9.1 and higher)
require "savon"
@ahaikal
ahaikal / gist:45e97e37fd72859fd9e2a3c2b99cba7a
Created May 20, 2016 14:09
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@ahaikal
ahaikal / Capybara.md
Created May 16, 2016 14:05 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above