Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@Zbizu
Zbizu / getOS.lua
Last active December 21, 2024 13:13
operating system (OS) detection in Lua
function getOS()
-- ask LuaJIT first
if jit then
return jit.os
end
-- Unix, Linux variants
local fh,err = assert(io.popen("uname -o 2>/dev/null","r"))
if fh then
osname = fh:read()
@rmtuckerphx
rmtuckerphx / direnv-win.md
Last active April 14, 2025 23:43
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 16, 2025 15:50
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, 2025 11:22
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 7, 2025 02:00
Vanilla JavaScript Quick Reference / Cheatsheet