Skip to content

Instantly share code, notes, and snippets.

View msalahz's full-sized avatar
🎯
Focusing

Mohammed Zaghloul msalahz

🎯
Focusing
View GitHub Profile
var arr = ["a", "b", "c"];
var obj = {};
/* Method no: 1 */
arr.forEach(function(item, index) {
obj[index] = item;
});
import Ember from 'ember';
const countries = Ember.A(["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas",
"Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","British Virgin Islands",
"Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica",
"Cote D Ivoire","Croatia","Cruise Ship","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea",
"Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana",
"Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana",
@msalahz
msalahz / squirt.js
Created January 14, 2018 00:32 — forked from joelpt/squirt.js
Manually calculate the square root of a number with Javascript
// The Babylonian Method
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
// @param n - the number to compute the square root of
// @param g - the best guess so far (can omit from initial call)
function squirt(n, g) {
if (!g) {
// Take an initial guess at the square root
g = n / 2.0;
}
var d = n / g; // Divide our guess into the number
@msalahz
msalahz / postgres_table_row_count.sql
Created December 24, 2017 21:53
Row counts for all tables in a postgres db.
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
@msalahz
msalahz / .gitlab-ci.yml
Created October 26, 2017 08:40 — forked from mupkoo/.gitlab-ci.yml
Using Ember-CLI with Chrome on GitLab CI
image: node:7.10
cache:
paths:
- node_modules/
- bower_components/
before_script:
# Install Chrome
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
@msalahz
msalahz / controllers.application.js
Last active October 26, 2017 13:43 — forked from poteto/controllers.application.js
ember-changeset-validations demo
import Ember from 'ember';
import AdultValidations from '../validations/adult';
import ChildValidations from '../validations/child';
import { reservedEmails } from '../validators/uniqueness';
import { schema } from '../models/user';
const { get } = Ember;
const { keys } = Object;
export default Ember.Controller.extend({
@msalahz
msalahz / Local SSL websites on macOS Sierra.md
Last active August 2, 2017 10:55 — forked from jonathantneal/README.md
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
import Ember from 'ember';
import hbs from "htmlbars-inline-precompile";
import Redux from 'redux';
const { createStore } = Redux;
const reducer = (state, action) => { console.log(state, action);
if(action.type === 'ADD'){
return Object.assign({}, state, {number: state.number + 1});
}
// Map accepts the projection function to be applied to each item in the source array, and returns the projected array.
Array.prototype.map = function (projectionFunction) {
var results = [];
this.forEach(function (itemInArray) {
// ------------ INSERT CODE HERE! ----------------------------
// Apply the projectionFunction to each item in the array and add
// each result to the results array.
// Note: you can add items to an array with the push() method.
// ------------ INSERT CODE HERE! ----------------------------
atom