Skip to content

Instantly share code, notes, and snippets.

[
{
"name": "Company application",
"fields": [
{
"component": "section",
"title": "Company Details",
"description": "Section for company details.",
"name": "companyDetails",
"fields": [
[
{
"value": 13590,
"label": "[13590] Glass Dealers & Glaziers"
},
{
"value": 90089,
"label": "[90089] Advertising Sign Cos.–Outdoor"
},
{
[
{
"value": 1860,
"label": "[1860] Abrasive Paper or Cloth Preparation (National)"
},
{
"value": 1748,
"label": "[1748] Abrasive Wheel Mfg. & Drivers (National)"
},
{
@mmahalwy
mmahalwy / rails_template.rb
Last active January 16, 2021 23:31
rails template
gem "rack-cors"
gem "pundit"
gem "graphql"
gem "friendly_id", "~> 5.2.4"
gem "awesome_print"
gem "strong_migrations"
gem "httparty"
gem "name_of_person"
@mmahalwy
mmahalwy / generate_factories.rb
Last active January 28, 2019 01:48
Generating Factories after model create for Rails
Rails.application.eager_load!
ApplicationRecord.subclasses.reject { |m| m.name =~ /HABTM/ || m.name =~ /Pg/ }.each do |model|
begin
model_relation = model.reflect_on_all_associations.map{ |r| [ r.foreign_key, r.name ] }.to_h
columns = model.columns.map { |c| [ c.name, c.type ] }.to_h
model_relation.keys.each { |k| columns.delete(k) }
puts "rails g factory_bot:model #{model.name} #{columns.map { |k, v| "#{k}:#{v}" }.join(' ')}"
`rails g factory_bot:model #{model.name} #{columns.map { |k, v| "#{k}:#{v}" }.join(' ')}`
@mmahalwy
mmahalwy / ProfileContainer.jsx
Last active May 31, 2018 06:33
Slim containers
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { follow } from '../actions/follow';
import { fetchUser } from '../actions/users';
import Navbar from '../components/Navbar';
import Profile from '../components/Profile';
function mapStateToProps(state, { match: { params } }) {
@mmahalwy
mmahalwy / .gitconfig
Created April 21, 2016 21:29
Awesome .gitconfig
[alias]
l = log --pretty=format:\"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]\" --decorate
g = log --oneline --decorate --graph
s = status -sb
co = checkout
b = branch -avv
ll = log --pretty=format:\"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]\" --decorate --numstat
lds = log --pretty=format:\"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]\" --decorate --date=short
ld = log --pretty=format:\"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]\" --decorate --date=relative
lc = log master..
@mmahalwy
mmahalwy / createFacebookTestUser.js
Created March 26, 2016 00:28 — forked from tildedave/createFacebookTestUser.js
Nightwatch Command for Creating Facebook Test User
var util = require('util');
var events = require('events');
var Promise = require('bluebird');
var request = Promise.promisify(require('request'));
var CreateFacebookTestUser = function() {
events.EventEmitter.call(this);
};
util.inherits(CreateFacebookTestUser, events.EventEmitter);
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@mmahalwy
mmahalwy / Before
Last active August 29, 2015 14:19
Transliteration algyyy
<?php
class TransliterationUtilities {
var $resultsPerPage;
function doTransliterationSearch($searchString, $page, $resultsPerPage){
$ans = array();
$normalized = $this->prepareText($searchString);
if (strlen($normalized) == 0) return $ans;
if (strlen($normalized) > 255)
$normalized = substr($normalized, 0, 200);