Skip to content

Instantly share code, notes, and snippets.

@javan
javan / key.md
Created February 28, 2023 14:53
Twitter (un)official Consumer Key

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA

namespace :haml do
desc "Convert HAML templates to ERB"
task :convert_to_erb do
# Assumes you have faraday in your Gemfile
conn = Faraday.new(url: "https://haml2erb.org") do |f|
f.request :json
f.response :json
end
haml_filenames = Dir["app/views/**/*.haml"]
const files = {
"m1.js": `import {func} from './m2.js'; console.log(func());`,
"m2.js": `export function func() { return 'abc'; }`
}
const urls = new Map
function getURL(filename) {
let url = urls.get(filename)
if (!url) {
@javan
javan / optimized-screenshots.md
Created July 8, 2019 18:51
macOS: Optimized Screenshots
😱 Before: ~/Desktop/Screen Shot….png 4.1 MB
🏆 After: ~/Screenshots/Screen Shot….png 937 KB

  ⤵

  1. Install https://pngquant.org/
    $ brew install pngquant
@javan
javan / add-sf-mono-to-firefox.md
Created June 11, 2019 19:37
Add SF Mono to Firefox (macOS only)

GitHub uses the following CSS font stack to display code:

font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace;

Chrome will use SFMono-Regular when that font is installed locally, but Firefox will not. Workaround: Add the following CSS to your Firefox profile's userContent.css file:

@font-face {
@javan
javan / test.html
Last active June 24, 2018 14:01 — forked from triskweline/test.html
Custom Elements v0 vs. DOMParser
<!doctype html>
<html>
<head>
<title>Custom elements test</title>
</head>
<body>
<h3>Custom elements from HTML</h3>
<ol class="from-html" start="0">
@javan
javan / webpack-fixme.md
Created May 30, 2018 14:33
Ideas for improving webpack.config.js

This is the example webpack.config.js on https://webpack.js.org/:

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  }
}
getHexColor = (color) ->
return "" unless color
return color if /^#/.test(color)
rgbValues = getRGBValues(color)
hexValues = rgbValues.map(numberToHex)
"#" + hexValues.join("")
numberToHex = (number) ->
"0#{number.toString(16)}".slice(-2).toUpperCase()
(async () => {
if (await mutionObserverIsBuggy()) {
patchInnerHTML()
}
})()
function mutionObserverIsBuggy(): Promise<boolean> {
return new Promise(resolve => {
const element = document.createElement("div")
element.innerHTML = "<a><em></em></a>"
@javan
javan / direct-uploads.md
Last active January 29, 2023 10:58
Active Storage direct uploads

direct-uploads

rails/activestorage#81

// direct_uploads.js

addEventListener("direct-upload:initialize", event => {
  const { target, detail } = event
  const { id, file } = detail