Skip to content

Instantly share code, notes, and snippets.

View zGrav's full-sized avatar

David Silva zGrav

View GitHub Profile
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;
@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"
@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 / jeremy.js
Created January 16, 2018 18:12
jeremy.js
const fs = require('fs');
(function() {
const file = '/tmp/file.txt';
const unlink = function() {
return new Promise((resolve, reject) => {
fs.unlink(file, function(e) {
if (e) { return reject(e); }
return resolve();
@zGrav
zGrav / jst.c
Last active January 27, 2018 15:26
#include <stdbool.h>
bool isvalueinarray(string val, int *arr, int size){
int i;
for (i=0; i < size; i++) {
if (arr[i].nome == val)
return true;
}
return false;
}
@zGrav
zGrav / .htaccess
Created February 8, 2018 09:49
rosafgit
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
@zGrav
zGrav / ovh-bk.sh
Last active October 21, 2020 09:46
#!/bin/bash
#
# Backing up the OVH server, checking the archive and sending it through FTP
#
BACKUPHOME=/home/backups
FTPUSER=ftpbackupser
FTPPASS=S0m3Th1nGH4rD
FTPSERVER=ftp.server.com
SERVER=youservername
@zGrav
zGrav / curlup.sh
Created February 8, 2018 15:46
curlup
find mydir -type f -exec curl -u xxx:psw --ftp-create-dirs -T {} ftp://xxx/{} \;
@zGrav
zGrav / curlup_log.sh
Created February 8, 2018 15:57
curlup_log
#!/bin/bash
LOG_FILE=/tmp/curlup_log.log
find mydir -type f -exec curl -u xxx:psw --ftp-create-dirs -T {} ftp://xxx/{} \; 2>&1 | tee ${LOG_FILE}
@zGrav
zGrav / lastlog_bash_clear.sh
Created February 8, 2018 17:58
clear lastlog and bash_history
cat /dev/null > /var/log/lastlog && cat /dev/null > ~/.bash_history && history -c && exit