Skip to content

Instantly share code, notes, and snippets.

@GiladShoham
GiladShoham / crossrider.sublime-completions
Created January 2, 2014 17:56
sublime text completions for crossrider
{
"completions":
[
{ "trigger": "a", "contents": "<a href=\"$1\">$0</a>" },
{ "trigger": "abbr", "contents": "<abbr>$0</abbr>" },
{ "trigger": "acronym", "contents": "<acronym>$0</acronym>" },
{ "trigger": "cr-closeTab", "contents": "appAPI.tabs.closeTab(tabInfo.tabId);" },
{ "trigger": "cr-createTab", "contents": "appAPI.tabs.create('${1:http://www.example.com}');" },
[
{
"keys": ["alt+m"],
"command": "markdown_preview",
"args":
{
"target": "browser",
"parser":"markdown"
}
},
@GiladShoham
GiladShoham / Authorization.jsx
Created April 3, 2017 09:00
React Authorizaion component
import React, { PropTypes } from 'react';
import apConnect from 'apollo-passportjs-react/lib/connect';
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
}
const Authorization = (allowedRoles) =>
(WrappedComponent, options = {}) => {
@GiladShoham
GiladShoham / regex.js
Created March 14, 2018 19:08
stuck regex
const jsdocRegex = /\/\*\*\s*\n([^*]*(\*[^/])?)*\*\//g;
const str4 = '/**\n * Basic accordion component\n * @render react\n * @example\n **/';
str4.match(jsdocRegex);
function* numbers() {
let index = 1;
while(true) {
yield index;
index = index + 1;
if (index > 10) {
break;
}
}
}
@GiladShoham
GiladShoham / README.md
Last active July 26, 2018 21:20 — forked from gbraad/README.md
Start C9 IDE from systemd

Start C9 IDE from systemd

Install Cloud9 first as [username]

$ su - [username]
$ wget https://github.com/gbraad/ansible-playbooks/raw/master/playbooks/install-c9sdk.yml
$ ansible-playbook install-c9sdk.yml
@GiladShoham
GiladShoham / import.sh
Created December 13, 2018 11:54
import all components from a bit scope
scope=$1
if [ -z "$scope" ]
then
echo "please provide scope"
else
components=$(bit ls ${scope} -j | jq -r '.[].id' | sed 's/\[Deprecated]//g')
num_components=$(echo "$components" | wc -w | xargs)
echo "found $num_components in scope $scope"
bit import $components
fi
@GiladShoham
GiladShoham / addManyAPI.js
Last active July 1, 2019 09:17
Bit add many - programmatic API example
const COMPONENT_ORIGINS = {
IMPORTED: 'IMPORTED',
AUTHORED: 'AUTHORED',
NESTED: 'NESTED' // which is a nested dependency
};
ComponentOrigin = $Keys<typeof COMPONENT_ORIGINS>;
type PathOsBased = string; // OS based format. On Windows it's Windows format, on Linux it's Linux format.
type PathOrDSL = PathOsBased | string; // can be a path or a DSL, e.g: tests/{PARENT}/{FILE_NAME}
type Warnings = {
//IMPORTANT - install this before: npm i child-process-promise --save-dev
/*
put this in your package.json script:
"install-collection": "node install-collection.js"
npm run install-collection <user>.<collection>
*/
const exec = require('child-process-promise').exec;
const args = process.argv;
const remote = args[2];
const { GraphQLClient, gql } = require('graphql-request');
const scopes = ['your-scopes'];
const uri = `https://symphony.bit.dev/graphql`;
const token = 'your-token';
const graphQLClient = new GraphQLClient(uri, {
headers: {
authorization: `Bearer ${token}`
}
});
const deleteScopeQuery = gql`