Skip to content

Instantly share code, notes, and snippets.

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

Mostafa Sholkamy shalkam

🏠
Working from home
View GitHub Profile
@shalkam
shalkam / mongoose-custom-type.js
Created February 12, 2017 19:59
creating a a custom mongoose schema type
'use strict';
var assert = require('assert');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost/db');
mongoose.set('debug', true);
class customType {
@shalkam
shalkam / mongoose-array-max.js
Last active February 12, 2017 20:18
setting maximum limit for an array
var peopleSchema = new Schema({
name: {
type: String,
required: true,
default: true
},
friends: {
type: [{
type: Schema.Types.ObjectId,
ref: 'peopleModel'
@shalkam
shalkam / react-context.js
Created April 7, 2017 13:13
Simple react context example
class Parent extends Component {
getChildContext() {
return {componentID: "123456"};
}
render() {
return <Child1 />
}
}
Parent.childContextTypes = {
@shalkam
shalkam / formsy-draft-wsisyg.js
Created May 18, 2017 13:04
Formsy react-draft-wysiwyg component
import React from 'react';
import Formsy, { HOC } from 'formsy-react';
import { Editor } from 'react-draft-wysiwyg';
import { EditorState, convertToRaw } from 'draft-js';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
import { stateToHTML } from 'draft-js-export-html';
import { stateFromHTML } from 'draft-js-import-html';
class Draft extends React.Component {
state = {
editorState: EditorState.createEmpty(),
@shalkam
shalkam / no-cache-electron.js
Created May 23, 2017 07:13
Load url into electron without caching
import { app, BrowserWindow, Menu, shell } from 'electron';
import Server from './server/server.js';
let menu;
let template;
let mainWindow = null;
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
@shalkam
shalkam / react-md.js
Last active June 13, 2017 14:17
Using Markdown inside React.js
import React, { Component } from 'react';
import Markdown from 'markdown-to-jsx';
import content from 'readme.md'; // Webpack should be configured to handle loading .md files (using raw-loader may be)
export default class Readme extends Component {
render() {
return (
<Markdown>
{content}
</Markdown>
@shalkam
shalkam / marked-html.js
Last active June 26, 2017 14:14
configuring marked renderer to work with markdown inside divs
const marked = require('marked');
const renderer = new marked.Renderer();
const cheerio = require('cheerio');
renderer.html = function(html) {
// marked has to be the first attribute
const $ = cheerio.load(html);
const markedDivs = $('div[marked]');
if (markedDivs.length > 0) {
// loop through all div tags with marked attribute

An answer from: https://stackoverflow.com/questions/11266478/git-add-remote-branch

I am not sure if you are trying to create a remote branch from a local branch or vice versa, so I've outlined both scenarios as well as provided information on merging the remote and local branches.

Creating a remote called "github":

git remote add github git://github.com/jdoe/coolapp.git git fetch github List all remote branches:

# Domain resource fields not added yet
type OperationOutcomeIssue {
severity: code!
code: code!
details: CodeableConcept
diagnostics: String
location: [String]
expression: [String]
@shalkam
shalkam / home-md.js
Last active July 26, 2017 13:18
Instructions for setting up react-intl
import home from './home.md';
import homeAr from './home-ar.md';
import homeEs from './home-es.md';
export default {
en: home,
ar: homeAr,
es: homeEs,
}