Skip to content

Instantly share code, notes, and snippets.

@thatisuday
thatisuday / io.js
Last active October 18, 2022 23:39
A sample JavaScript program to manage application files.
const { ipcMain } = require( 'electron' );
const path = require( 'path' );
const fs = require( 'fs-extra' );
const os = require( 'os' );
const open = require( 'open' );
const chokidar = require( 'chokidar' );
// local dependencies
const notification = require( './notification' );
@Sensanaty
Sensanaty / cors.rb
Last active June 20, 2020 14:15
Rails CORS allow all localhost domains
# initializers/cors.rb
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
# Allow localhost in CORS
origins /(https?:\/\/)((localhost:)|(127.0.0.1:))/
resource '*',
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
@Sensanaty
Sensanaty / _font.scss
Last active May 29, 2020 23:41
Font SCSS Mixin
@mixin font($font-family, $font-file) {
@font-face {
font-family: $font-family;
src: url($font-file +'.eot');
// If the user has the font locally, use that
src: local($font-file),
url($font-file + '.eot?#iefix') format('embedded-opentype'),
url($font-file + '.woff') format('woff'),
url($font-file + '.ttf') format('truetype'),
url($font-file + '.svg#aller') format('svg');
@Sensanaty
Sensanaty / Miscellaneous.rb
Last active December 14, 2019 12:44
Ruby Service Example
# app/controllers/Miscellaneous.rb
# This is where we will call the Service. Imagine that this file is somewhere else in the projects, like maybe a controller
place_id = GoogleAPIService.fetch_id(-15.34095, 32.53719)
@dodying
dodying / favicon.md
Last active April 25, 2024 09:21
[Get Favicon] #api #favicon
  • DuckDuckGo https://icons.duckduckgo.com/ip2/{hostname}.ico
  • Google https://www.google.com/s2/favicons?domain_url={hostname}
  • Yandex https://favicon.yandex.net/favicon/{hostname1}/{hostname2}/
  • allesedv https://f1.allesedv.com/16/{hostname}
  • http://grab-favicons.herokuapp.com/api/v1/grab-favicons/?url={hostname}
  • https://besticon-demo.herokuapp.com/icon?url={hostname}&size=80..120..200
  • http://favicongrabber.com/service-api-reference
@soderlind
soderlind / Install.txt
Last active March 5, 2024 20:30
macOS DoH! (DNS over HTTPS) using cloudflared
1) Install cloudflared using homebrew:
brew install cloudflare/cloudflare/cloudflared
2) Create /usr/local/etc/cloudflared/config.yaml, with the following content
proxy-dns: true
proxy-dns-upstream:
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query
@mkremins
mkremins / pbcopy.js
Created April 17, 2014 21:41
node.js: put text into OS X clipboard
function pbcopy(data) {
var proc = require('child_process').spawn('pbcopy');
proc.stdin.write(data);
proc.stdin.end();
}
@alexdiliberto
alexdiliberto / ember-list-all-routes.js
Last active April 21, 2023 08:59
List all Ember route paths. (Just paste this in the console of your favorite Ember app)
// NOTE: `AppName` is simply your PascalCase application name (`modulePrefix` key from `../config/environment.js`)
window.AppName.__container__.lookup('service:router')._router._routerMicrolib.recognizer.names;
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000