Skip to content

Instantly share code, notes, and snippets.

@nberlette
nberlette / str.scss
Last active January 10, 2024 22:42
SASS string functions for kebabCase, camelCase, titleCase, etc.
/* * * * * * * * * * * * * * * * * * * * * * * * *
SASS string functions:
camelCase, kebabCase, titleCase, toLower, etc.
-------------------------------------------------
2021 Nicholas Berlette - https://git.io/Js3HD
* * * * * * * * * * * * * * * * * * * * * * * * */
@use "sass:string";
/*
upperCase($string)
import React, { useState, useLayoutEffect } from 'react'
const useWindowSize = () => {
const [size, setSize] = useState([0, 0])
useLayoutEffect(() => {
const updateSize = () => {
setSize([window.innerWidth, window.innerHeight])
}
@maxdavid
maxdavid / tmuxfixer.js
Created May 21, 2019 21:31
Simple script for updating tmux config files, converting deprecated -fg, -bg, and -attr options to the combined -style option
#!/usr/bin/env node
/*
tmuxfixer.js
USAGE:
$ node tmuxfixer.js old-conf-path [new-conf-path]
PURPOSE & CONTEXT: This script takes in a tmux configuration file and combines
all deprecated -fg, -bg, and -attr into a single -style option line.
@rikukissa
rikukissa / POST.md
Last active May 6, 2024 11:52
React Hook prompting the user to "Add to homescreen" 🏠 #PWA #React
title slug createdAt language preview
React Hook prompting the user to "Add to homescreen"
react-hook-prompting-the-user-to-add
2018-11-29T20:35:02Z
en
Simple React Hook for showing the user a custom "Add to homescreen" prompt.

React Hook for showing custom "Add to homescreen" prompt

@katopz
katopz / gql_query_search_stargazers.gql
Created November 26, 2016 04:55
GraphQL Github Example : Search for top ten stargazers via query
// Try at : https://graphql-explorer.githubapp.com/
// With query variables below
// { "queryString": "language:JavaScript stars:>10000" }
query SearchMostTop10Star($queryString: String!) {
search(query: $queryString, type: REPOSITORY, first: 10) {
repositoryCount
edges {
node {
... on Repository {
@esamattis
esamattis / application.html.erb
Last active May 19, 2019 00:36
React hot reloading with Webpack for Ruby on Rails
<script charset="utf-8">
<% if ENV["RAILS_ENV"] == "production" %>
var script = "/react-app-bundle.js";
<% else %>
console.warn("Development mode. Make sure to start 'node devServer.js'");
var script = "http://" + (location.host || 'localhost').split(':')[0] + ":4000/react-app-bundle.js"
<% end %>
document.write('<script src="' + script + '"></' + 'script>');
</script>
@code0100fun
code0100fun / tests_acceptance_foo-test.js
Last active July 9, 2018 01:05
Ember CLI QUnit text content helpers
// tests/acceptance/foo-test.js
// Assert that text should be found
assert.hasText('Not Found'); // Error: Could not find text "Not Found" on the page
// Provide custom message
assert.hasText('Not Found', 'Expected to find "Not Found"'); // Error: Expected to find "Not Found"
// Find any number of elements containing the query text
text('Found'); // [<div>Found</div>, <input value="Found">]
@fritz-c
fritz-c / git-recentco
Last active June 7, 2024 17:41 — forked from jordan-brough/git-recent
Git: Check out a branch from a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/fritz-c/c1e528b09bc1c0827a3c
# Original: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# Download this script as "git-recentco" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recentco` from inside any git repo.
# Example:
#
@JoseJRVazquez
JoseJRVazquez / Advanced Classes
Last active August 10, 2018 20:12
My Lesson in Advanced Classes in Ruby
Ok, so Inheritance
its not just for young white dudes waiting for their grandparents to fucking keel over at 82.
In ruby, Inheritance allows one class to inherit from another class attributes and behaviors (methods) that it didnt have before. The inheriter, much like a young white male, is the child class. The class that it inherits from, rather than being his old money grandparents, is the Parent Class. The lesson says Inheritance is designated with a < symbol, for example:
class Daughter < Father
end
wow, quick right. So for that, the daughter is getting methods from the father. Simple right. But lets go deeper and se how fucked up this can really get for those of us in the cheap seats.