Skip to content

Instantly share code, notes, and snippets.

View kevin50406418's full-sized avatar

Jing Xun Lai kevin50406418

  • 127.0.0.1
View GitHub Profile
@kevin50406418
kevin50406418 / multi-level-group-by.js
Created July 4, 2021 09:07 — forked from fatihky/multi-level-group-by.js
multi level group by, lodash, collections
const _ = require('lodash')
function genrows(groups, groupKey) {
return _.toPairs(groups)
.map(([key, data]) => ({[groupKey]: key, data}))
}
function gengroups(arr, iteratee, key) {
const grouped = _.groupBy(arr, iteratee)
return genrows(grouped, key)
@kevin50406418
kevin50406418 / svn-to-git.md
Created April 30, 2019 14:51 — forked from barrysteyn/svn-to-git.md
Migrate From SVN To GIT
@kevin50406418
kevin50406418 / Event-stream based GraphQL subscriptions.md
Created March 18, 2019 13:43 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@kevin50406418
kevin50406418 / How to use Images as Radio buttons.md
Created April 2, 2018 10:58 — forked from rcotrina94/How to use Images as Radio buttons.md
How to use images for radio buttons (input-radio).
@kevin50406418
kevin50406418 / Github Webhook Tutorial.md
Created February 7, 2018 02:15 — forked from jagrosh/Github Webhook Tutorial.md
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@kevin50406418
kevin50406418 / SimplePagination.vue
Created January 19, 2018 02:51 — forked from saqueib/SimplePagination.vue
VueJS pagination component to paginate anything in Laravel, checkout the tutorial on http://wp.me/p8cmxL-b7 by www.qcode.in
<template>
<div :class="{'loading': loading}" class="pager-data-wrapper">
<!-- Pagination Slot -->
<slot :result="getResult()">
<div class="text-center alert-info pb-3">
<span v-if="!loading">
{{ result.length }} items found. render it using v-for="item in result"
</span>
<span v-if="loading">
@kevin50406418
kevin50406418 / Update remote repo
Created January 9, 2018 14:57 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@kevin50406418
kevin50406418 / gist:2e897a1c8174b46d7760f883174f1b01
Created January 3, 2018 04:39
prettify var_export for php 5.4
$config = preg_replace('#=>\s*array \(#', '=> [', $config);
$config = preg_replace('#\),#', '],', $config);
$config = preg_replace('#,(\s*)\]#', '$1]', $config);
$config = preg_replace('#\d+ => #', '', $config);
$config = preg_replace('#\[\s+\]#', '[]', $config);
$config = str_replace(' ', "\t", $config);
@kevin50406418
kevin50406418 / RouteServiceProvider.php
Created December 25, 2017 06:38 — forked from phillipsharring/RouteServiceProvider.php
Database Driven Routes in Laravel 5.1
<?php
// ...
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
@kevin50406418
kevin50406418 / cluster-up.sh
Created June 11, 2017 12:23 — forked from cneud/cluster-up.sh
Bash script containing all steps required to fire up a CDH cluster
#!/bin/bash
# Hadoop cluster start-up script
#
# 1. Format the namenode (only required on 1st start!)
# sudo -u hdfs hdfs namenode -format
# 2. Start HDFS
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
# 3. Create the /temp directory