Skip to content

Instantly share code, notes, and snippets.

View eyalcohen4's full-sized avatar
🏠
Working from home

Eyal Cohen eyalcohen4

🏠
Working from home
View GitHub Profile
@remino
remino / msconvert.js
Created January 5, 2012 05:37
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
@nfarring
nfarring / gist:1904139
Created February 24, 2012 22:14
composer.json snippet for installing phpredis using composer
{
"type": "package",
"package": {
"name": "phpredis/phpredis",
"version": "2.1.3",
"dist": {
"url": "https://github.com/nicolasff/phpredis/zipball/2.1.3",
"type": "zip"
}
}
@killercup
killercup / api.js
Last active June 10, 2021 22:02
Streamed CSV Export using node-restify and mongoose
/**
* # Some Demo API Service
*/
var restify = require('restify');
var map = require('map-stream');
var csvify = require('../helpers/csvify');
var Team = require("../models").Team;
@gunjanpatel
gunjanpatel / amazon-ec2-ftp.md
Last active October 10, 2023 15:31
amazon ec2 LAMP and FTP installation and setup
@chantastic
chantastic / on-jsx.markdown
Last active May 30, 2024 13:11
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

function debounce( fn, threshold ) {
var timeout;
return function() {
clearTimeout( timeout );
var args = arguments;
var _this = this;
timeout = setTimeout( function() {
fn.apply( _this, args );
}, threshold || 100 );
}
@richardgill
richardgill / normalizeStyle.js
Created December 2, 2016 16:31
Makes React Native components look more consistent on different device sizes. The base size is an iPhone 6.
import _ from 'lodash'
import { Dimensions, PixelRatio } from 'react-native'
import { platformIsIos } from 'expresso-common/common/platform'
const { height } = Dimensions.get('window')
const iphone6Height = 667
const pixelRatio = PixelRatio.get()
const fieldsToNormalize = [
'fontSize',
'lineHeight',
import React, { Component, PropTypes } from 'react'
import {
Text,
View,
ScrollView
} from 'react-native'
import Redirect from 'react-router/Redirect'
import Match from 'react-router/Match'
import React, { Component, PropTypes } from 'react'
import {
Text,
View,
TouchableHighlight,
ScrollView,
StatusBar,
Dimensions,
Animated
@freak4pc
freak4pc / IsraeliID.Validator.js
Last active June 17, 2024 16:19
Israeli ID Validator (Javascript)
function isValidIsraeliID(id) {
var id = String(id).trim();
if (id.length > 9 || id.length < 5 || isNaN(id)) return false;
// Pad string with zeros up to 9 digits
id = id.length < 9 ? ("00000000" + id).slice(-9) : id;
return Array
.from(id, Number)
.reduce((counter, digit, i) => {