Skip to content

Instantly share code, notes, and snippets.

Dan Riti danriti

Block or report user

Report or block danriti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sqren
sqren / determine-changed-props.js
Last active Oct 23, 2019
Determine which props causes React components to re-render
View determine-changed-props.js
import React, { Component } from 'react';
export default function withPropsChecker(WrappedComponent) {
return class PropsChecker extends Component {
componentWillReceiveProps(nextProps) {
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== this.props[key];
})
.map(key => {
@zabirauf
zabirauf / gulpfile.js
Created Oct 19, 2015
Gulpfile for a frontend in React + ES6
View gulpfile.js
var gulp = require('gulp'),
gutil = require('gulp-util'),
babelify = require('babelify'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
watchify = require('watchify'),
browserSync = require('browser-sync').create();
var paths = {
HTML: 'src/index.html',
@pbertera
pbertera / freshdesk-sso.py
Last active Mar 14, 2019
Freshdesk Single sign-on in Python
View freshdesk-sso.py
import time
import hashlib
import hmac
import urllib
def get_sso_url(email, name, base_url, key, redirect_url=None, phone=None, company=None):
"""This function returns the Freshdesk SSO URL.
For more info look at https://goo.gl/NISgpr
"""
utctime = int(time.time())
@hawkup
hawkup / Install etcd On Ubuntu 14.04.md
Created Jul 4, 2015
Install etcd On Ubuntu 14.04
View Install etcd On Ubuntu 14.04.md
  • Install
curl -L  https://github.com/coreos/etcd/releases/download/v2.1.0-rc.0/etcd-v2.1.0-rc.0-linux-amd64.tar.gz -o etcd-v2.1.0-rc.0-linux-amd64.tar.gz
tar xzvf etcd-v2.1.0-rc.0-linux-amd64.tar.gz
cd etcd-v2.1.0-rc.0-linux-amd64
./etcd
  • by default etcd listening on port 2379 for client communication and on port 2380 for server to server communication

  • Test

@danriti
danriti / README.md
Last active Apr 18, 2019
Line Profiling in Python
View README.md

Install the line_profiler module:

[driti@ubuntu ]$ pip install line_profiler

Add the @profile decorator and run:

[driti@ubuntu ]$ kernprof.py -l -v example.py
@danriti
danriti / comments.js
Last active Apr 30, 2018
Display all hidden inline comments on a Github issue/pull request. Just copy+pasta into your JS console or make a bookmarklet.
View comments.js
$('.outdated-diff-comment-container').addClass('open');
@jimdoescode
jimdoescode / DateFromNow.js
Last active Dec 22, 2015
Easily format a past date with this object. It has two public methods one that will give a rough estimate with the largest part of time. Something like: 2 hours ago. The second will give you all the parts of time that have elapsed as an object. Parts that are too large are returned as null. Check the comments for more information.
View DateFromNow.js
/*
License: MIT
Easily formattable date difference.
DateFromNow(someDate).simple(); //ex. returns '3 days ago';
DateFromNow(someDate).parts(); //ex. returns {years: null, months: null, days: 3, hours: 8, minutes: 52, seconds: 43};
*/
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active Oct 17, 2019
CriticalCSS Bookmarklet and Devtool Snippet.js
View criticalcss-bookmarklet-devtool-snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
View bad_kitty.rb
# coding: utf-8
# Can ruby have method names have newlines/be crazy?
class BadKitty
FACE = "
|\\_/|
/ @ @ \\
( > º < )
`>>x<<´
View gist:5895737
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
# Sometimes need more flexibility --> use properties
class Point:
def __init__(self, x, y):
self._x, self._y = x, y
You can’t perform that action at this time.