Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@rmtuckerphx
rmtuckerphx / direnv-win.md
Last active January 12, 2024 18:32
Steps to install direnv on Windows

direnv on Windows

Overview

In JavaScript projects, I used to use dotenv so that I could put local environment variables in a .env file for local development. But dotenv requires you to add code to your project. With direnv, you can put local env vars in a .envrc file and those env vars are loaded automatically in the shell.

Steps to install

For these steps, it is assummed that you have installed Git Bash on Windows. I also use VSCode as my editor.

  1. Create a folder such as c:\tools to put the direnv.exe file and add it to the Windows PATH
@AndyObtiva
AndyObtiva / ruby-case-statement-array-include-pattern-matching.rb
Created January 1, 2021 01:15
How to test Array Inclusion in Ruby Case Statements via Pattern Matching
# Relating to [YASL](https://github.com/AndyObtiva/yasl)
def dump_ruby_basic_data_type_data(object)
case object.class.ancestors.map(&:name)
in [*, 'Time', *]
object.to_datetime.marshal_dump
in [*, 'Date', *]
object.marshal_dump
in [*, 'Complex', *] | [*, 'Rational', *] | [*, 'Regexp', *] | [*, 'Symbol', *] | [*, 'BigDecimal', *]
object.to_s
in [*, 'Set', *]
class Solution {
public:
vector<string> findItinerary(vector<vector<string>>& tickets) {
unordered_map<string,multiset<string>> adj;
vector<string> ans;
int n=tickets.size();
//Make graph
for(int i=0;i<n;++i)
adj[tickets[i][0]].insert(tickets[i][1]);
@ChristopherA
ChristopherA / brew-bundle-brewfile-tips.md
Last active April 19, 2024 06:56
Brew Bundle Brewfile Tips

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active April 19, 2024 04:06
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

port module Spelling exposing (..)
import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String
main =
@ccnokes
ccnokes / store.js
Created September 17, 2016 21:49
Example "store" for user data in an Electron app
const electron = require('electron');
const path = require('path');
const fs = require('fs');
class Store {
constructor(opts) {
// Renderer process has to get `app` module via `remote`, whereas the main process can get it directly
// app.getPath('userData') will return a string of the user's app data directory path.
const userDataPath = (electron.app || electron.remote.app).getPath('userData');
// We'll use the `configName` property to set the file name and path.join to bring it all together as a string
@goizueta
goizueta / getPastPrsForUser.js
Last active June 13, 2016 16:22
Get past PRs. Github API only goes back 300 events (comments, commits, pushes, pulls, etc...)
var GitHubApi = require("github");
var user = "kn9ts";
var pullRequests = [];
var github = new GitHubApi({
// optional
debug: false,
protocol: "https",
host: "api.github.com", // should be api.github.com for GitHub
pathPrefix: "", // for some GHEs; none for GitHub
timeout: 5000,
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active April 17, 2024 18:56
Vanilla JavaScript Quick Reference / Cheatsheet
@jasongilman
jasongilman / atom_clojure_setup.md
Last active January 11, 2024 09:13
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.