Skip to content

Instantly share code, notes, and snippets.

View kirillzubovsky's full-sized avatar
💭
High on catnip 🙀

Kirill Zubovsky kirillzubovsky

💭
High on catnip 🙀
View GitHub Profile
@FlorianRappl
FlorianRappl / useCarousel.ts
Last active March 27, 2024 13:58
The generic useCarousel hook.
import { useReducer, useEffect } from 'react';
import { useSwipeable, SwipeableHandlers, EventData } from 'react-swipeable';
function previous(length: number, current: number) {
return (current - 1 + length) % length;
}
function next(length: number, current: number) {
return (current + 1) % length;
}
module Model
def initialize(attributes)
self.attributes = attributes
end
def attributes=(hash)
hash.each do |k, v|
send :"#{k}=", v
end
end
@katydecorah
katydecorah / script.js
Last active March 27, 2021 19:28
Draft emails in Gmail from a Google spreadsheet https://katydecorah.com/code/google-sheets-to-gmail/
var EMAIL_DRAFTED = "EMAIL DRAFTED";
function draftMyEmails() {
var sheet = SpreadsheetApp.getActiveSheet(); // Use data from the active sheet
var startRow = 2; // First row of data to process
var numRows = sheet.getLastRow() - 1; // Number of rows to process
var lastColumn = sheet.getLastColumn(); // Last column
var dataRange = sheet.getRange(startRow, 1, numRows, lastColumn) // Fetch the data range of the active sheet
var data = dataRange.getValues(); // Fetch values for each row in the range
@dmnsgn
dmnsgn / listAllEventListeners.js
Created April 5, 2017 15:40
List all event listeners in a document
const listeners = (function listAllEventListeners() {
let elements = [];
const allElements = document.querySelectorAll('*');
const types = [];
for (let ev in window) {
if (/^on/.test(ev)) types[types.length] = ev;
}
for (let i = 0; i < allElements.length; i++) {
const currentElement = allElements[i];
@chrismdp
chrismdp / s3.sh
Last active March 5, 2024 12:57
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active April 21, 2024 02:41
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
CYN='\e[1;96m'
# git dirty branch
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "(._.)"
}
function parse_git_clean {
@fredsterss
fredsterss / loading.coffee
Created June 4, 2013 00:10
Elegant loading
# handle ajax events (loading and auth errors)
$(document).ajaxStart ->
settings = lines: 12, length: 6, width: 4, radius: 8, trail: 75, color: '#fff'
$('.loading-main').html new r.ui.spinner( settings ).spin().el
$('[data-section=logo]').addClass('loading')
$(document).ajaxStop ->
$('[data-section=logo]').removeClass('loading')
$(document).ajaxComplete (e, xhr, options) ->
r.errorHandler.handle(xhr)
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@font-face {
font-family: 'EntypoRegular';
src: url('font/entypo.eot');
src: url('font/entypo.eot?#iefix') format('embedded-opentype'),
url('font/entypo.woff') format('woff'),
url('font/entypo.ttf') format('truetype'),
url('font/entypo.svg#EntypoRegular') format('svg');
font-weight: normal;
font-style: normal;
}