Skip to content

Instantly share code, notes, and snippets.

@cuth
cuth / debug-scroll.md
Last active February 7, 2024 18:17
Find the elements that are causing a horizontal scroll. Based on http://css-tricks.com/findingfixing-unintended-body-overflow/

Debug Horizontal Scroll

(function (d) {
    var w = d.documentElement.offsetWidth,
        t = d.createTreeWalker(d.body, NodeFilter.SHOW_ELEMENT),
        b;
    while (t.nextNode()) {
        b = t.currentNode.getBoundingClientRect();
 if (b.right > w || b.left < 0) {
@jgornick
jgornick / gist:0b10798608193ba4fd6d
Last active January 5, 2024 00:02
Nginx: Advanced proxy_pass depending on file exists
server {
listen 443;
server_name my.domain.com;
root /var/www/my.domain.com;
ssl on;
ssl_certificate /usr/local/etc/ssl/star.crt;
ssl_certificate_key /usr/local/etc/ssl/star.key;
@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@sokratisg
sokratisg / sysctl.conf
Last active January 5, 2024 00:03
Tuned sysctl.conf for use by CentOS/RHEL 6.x or later
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Turn on execshield
# 0 completely disables ExecShield and Address Space Layout Randomization
# 1 enables them ONLY if the application bits for these protections are set to “enable”
# 2 enables them by default, except if the application bits are set to “disable”
# 3 enables them always, whatever the application bits
@falexandrou
falexandrou / view-pdf.js
Last active August 29, 2015 13:57
Display PDF files inline
/**
* When browser supports inline pdfs
* There is no need to append a large jquery plugin that displays them inline.
*
* You can actually use an iframe (and style it appropriately)
* or a link whenever inline PDF viewing is not supported
*
* This function is fairly simple and it's only for demo purposes
*/
function appendPdf(id, url) {
@sergeifilippov
sergeifilippov / domain-nginx.conf
Created February 10, 2014 03:22
linux-dash with nginx
server {
server_name $domain_name;
root /var/www;
index index.html index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Cache static files for as long as possible
location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
try_files $uri =404;
@rroblak
rroblak / pac_aliases
Last active April 12, 2023 13:49
Package manager-independent bash aliases
# paci - install one or more packages
# pacu - upgrade all packages to their newest version
# pacr - uninstall one or more packages
# pacs - search for a package using one or more keywords
# pacinfo - show information about a package
# pacinstalled - show if a package is installed
# paca - list all installed packages
# paclo - list all packages which are orphaned
# pacdnc - delete all not currently installed package files
# pacfiles - list all files installed by a given package
@rastating
rastating / USNetflixHosts
Created November 27, 2013 22:04
A hosts file to use to access the US Netflix using the Unblock US service without using their DNS for all of your traffic.
# Hosts file to access US Netflix using Unblock US without their DNS.
67.216.222.61 movies.netflix.com
67.216.222.65 cbp-us.nccp.netflix.com
67.216.222.130 movies1.netflix.com
67.216.222.104 movies2.netflix.com
147.255.171.14 netflix.com
147.255.171.7 moviecontrol.netflix.com
69.197.181.166 api-global.netflix.com
67.216.222.83 api-us.netflix.com
147.255.227.2 api.netflix.com
@paulosborne
paulosborne / gist:7640679
Created November 25, 2013 12:40
Hipster indexOf
var message = "hello, how are you Tal?";
if (~message.indexOf('Tal')) {
console.log('found matching text');
}
@pauloricardomg
pauloricardomg / cors.nginxconf
Last active March 8, 2024 18:31
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {