Skip to content

Instantly share code, notes, and snippets.

View zGrav's full-sized avatar

David Silva zGrav

View GitHub Profile
@zGrav
zGrav / paste.js
Last active January 7, 2018 06:13
import Html from 'slate-html-serializer';
// import React from 'react';
// import { FunctionTypes } from 'constants/editor/ViewModel';
// import { Nodes } from 'components/editor';
import { getEventTransfer } from 'slate-react';
import { BlockTypes } from 'constants/editor';
import { Block } from 'slate';
@zGrav
zGrav / .zshrc
Created November 27, 2017 13:41
.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/Users/zgrav/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="agnoster"
function getYfromElem(query) {
return window.pageYOffset + document.querySelector(query).getBoundingClientRect().top;
}
function smoothAsButter(elem, dur) {
var startY = window.pageYOffset;
var elemY = getYfromElem(elem);
var resultY = document.body.scrollHeight - elemY < window.innerHeight ? document.body.scrollHeight - window.innerHeight : elemY;
var diff = resultY - startY;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.commons.lang3.StringUtils;
public class TableRenderer {
@zGrav
zGrav / hubot.sh
Created October 13, 2017 12:50
backup of hubot daemon, could be useful for future projects where i need a simple background/debug daemon
#!/bin/sh
# This assumes you have:
# 1) A user called hubot and paths manually set.
#
# To set the adapter either edit bin/hubot to specify what you want or append
# `-- -a slack` to the $DAEMON variable below.
#
### BEGIN INIT INFO
# Provides: hubot
public class StackTrace {
public static void main(String[] args) {
recurse(10);
}
static void recurse(int depth) {
for (StackTraceElement each: new Exception().getStackTrace()) System.out.println(each);
if (depth > 0) recurse(depth - 1);
System.out.println(depth);
def f(n):
f.count += 1
if n == 1:
return 1
else:
return n * f(n-1)
f.count = 0;
print f(5)
@zGrav
zGrav / keybase.md
Created July 31, 2017 21:14
Keybase

Keybase proof

I hereby claim:

  • I am zgrav on github.
  • I am notzgrav (https://keybase.io/notzgrav) on keybase.
  • I have a public key ASCrPNKUDgX4DaC3Ia_EQJJQzYxo_lQ2hzu6RVDXXP8vmgo

To claim this, I am signing this object:

# 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 ->
@zGrav
zGrav / palindromesolution.java
Created April 11, 2017 15:31
palindromesolution
class Solution {
public static void main(String[] args) {
String PString = "0 man, a plan, a canal: Panam0";
String nonPString = "race a car";
System.out.println("is PString a Palindrome? : " + isPalindrome(PString));
System.out.println("is nonPString a Palindrome? : " + isPalindrome(nonPString));
}
public static boolean isPalindrome(String str) {