Skip to content

Instantly share code, notes, and snippets.

View danriti's full-sized avatar

Dan Riti danriti

View GitHub Profile
@sorenlouv
sorenlouv / determine-changed-props.js
Last active April 18, 2024 16:21
Determine which props causes React components to re-render
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 => {
@nodkz
nodkz / apolloServer2019.ts
Last active August 3, 2022 11:17
GraphQL error tracking with sentry.io (ApolloServer 2019)
import express from 'express';
import { ApolloServer } from 'apollo-server-express';
import { ApolloServerPlugin } from 'apollo-server-plugin-base';
import * as Sentry from '@sentry/node';
Sentry.init({
environment: process.env.APP_ENV,
// see why we use APP_NAME here: https://github.com/getsentry/sentry-cli/issues/482
release: `${process.env.APP_NAME}-${process.env.APP_REVISION}` || '0.0.1',
dsn: process.env.SENTRY_DSN,
@zabirauf
zabirauf / gulpfile.js
Created October 19, 2015 00:11
Gulpfile for a frontend in React + ES6
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 March 14, 2019 13:05
Freshdesk Single sign-on in Python
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 July 4, 2015 22:06
Install etcd On Ubuntu 14.04
  • 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 February 26, 2022 07:20
Line Profiling in Python

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 April 30, 2018 20:50
Display all hidden inline comments on a Github issue/pull request. Just copy+pasta into your JS console or make a bookmarklet.
$('.outdated-diff-comment-container').addClass('open');
@jimdoescode
jimdoescode / DateFromNow.js
Last active December 22, 2015 08:19
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.
/*
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 April 2, 2024 02:45
CriticalCSS Bookmarklet and 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(": ");
# coding: utf-8
# Can ruby have method names have newlines/be crazy?
class BadKitty
FACE = "
|\\_/|
/ @ @ \\
( > º < )
`>>x<<´