Skip to content

Instantly share code, notes, and snippets.

View arielsalminen's full-sized avatar
🌸

Ariel Salminen arielsalminen

🌸
View GitHub Profile
@addisonschultz
addisonschultz / useScript.tsx
Last active October 28, 2023 10:02
A React hook that lets you add script tags to a component. Useful when needing to load scripts for components in Framer X.
import * as React from "react"
import { useState, useEffect } from "react"
// Hook
let cachedScripts = []
export function useScript(src) {
// Keeping track of script loaded and error state
const [state, setState] = useState({
loaded: false,
@didoo
didoo / git-log-parser.js
Created January 25, 2019 16:52
Git Log Parser & Aggregator
/* eslint-env node */
/* eslint-disable no-console, dot-notation */
const fse = require('fs-extra');
const readline = require('readline');
// const platform = 'mw_less';
// const platform = 'mw_scss';
const platform = 'cosmos';
@rsms
rsms / figma-project-stats.js
Created June 21, 2018 19:17
Script that generates statistics for a Figma project, like number of files, frames, versions etc
//
// Figma project stats
// Pulls statistics like number of files, frames, versions etc for a project.
//
// Usage:
// export FIGMA_API_ACCESS_TOKEN='your-token'
// node figma-project-stats.js <project-id>
//
// You can generate tokens in your account settings or at
// https://www.figma.com/developers/explorer#personal-access-token
@samthor
samthor / safari-nomodule.js
Last active February 14, 2024 02:54
Safari 10.1 `nomodule` support
// UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that
// does not support `nomodule` is probably not being used anywhere. The code below is left
// for posterity.
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
@russellbeattie
russellbeattie / aws-twitter-search-bot.js
Last active January 19, 2016 00:42
AWS Lambda Twitter Search Bot... uses S3 for persistence and SNS to send out messages.
var querystring = require('querystring');
var https = require('https');
var aws = require('aws-sdk');
var s3 = new aws.S3();
var sns = new aws.SNS({
region: 'us-east-1'
});
var query = '#SEARCH TERM HERE';
@jeremyruppel
jeremyruppel / asset_helper.rb
Created June 10, 2013 19:24
Inline asset helpers for middleman.
module AssetHelper
##
# Renders a stylesheet asset inline.
def inline_stylesheet( name )
content_tag :style do
sprockets[ "#{name}.css" ].to_s
end
end
@arielsalminen
arielsalminen / nav.html
Last active December 14, 2015 12:18
Simple responsive navigation toggle script without library dependencies and with touch screen support (349 bytes minified and gzipped). Live demo: http://codepen.io/viljamis/full/gAatl
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>Nav toggle</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<ol id="nav" class="closed">
<li class="active"><a href="#">Home</a></li>
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
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:

@stopsatgreen
stopsatgreen / Placeholder Polyfill
Created December 18, 2012 10:09
Detect placeholder support in the browser and use value if it isn't present.
function hasPlaceHolder() {
return 'placeholder' in document.createElement('input');
}
function html5forms() {
var formPlaceholder = hasPlaceHolder();
if (formPlaceholder === false) {
$('input[type=text]').each(function() {
if($(this).attr('placeholder')) {
var placeholderText = $(this).attr('placeholder');
@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows: