Skip to content

Instantly share code, notes, and snippets.

Karl karlcoelho

Block or report user

Report or block karlcoelho

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@karlcoelho
karlcoelho / darken.css
Created Feb 24, 2016
darken background image so overtext is clear
View darken.css
.main {
background-image: linear-gradient(
rgba(0, 0, 0, 0.6),
rgba(0, 0, 0, 0.6)
), url(image.jpg);
}
@karlcoelho
karlcoelho / random.rb
Created Feb 19, 2016
Generate a random string in Ruby
View random.rb
def random_string(length)
rand(36**length).to_s(36)
end
# rand(36**length).to_s(36)
@karlcoelho
karlcoelho / app.rb
Created Jan 30, 2016
CORS for Sinatra
View app.rb
before do
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Headers'] = 'accept, authorization, origin'
end
options '*' do
response.headers['Allow'] = 'HEAD,GET,PUT,DELETE,OPTIONS,POST'
response.headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Cache-Control, Accept'
@karlcoelho
karlcoelho / sqlite2pg.sh
Created Dec 15, 2015 — forked from eclubb/sqlite2pg.sh
Script to import SQLite3 database into PostgreSQL
View sqlite2pg.sh
#!/bin/sh
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
SQLITE_DB_PATH=$1
PG_DB_NAME=$2
PG_USER_NAME=$3
View file.php
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
@karlcoelho
karlcoelho / background-image.css
Created Nov 4, 2015
Stretch the background image over the whole page
View background-image.css
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
@karlcoelho
karlcoelho / rendering.css
Created Oct 31, 2015
Make text look good with CSS
View rendering.css
-webkit-font-smoothing: antialiased;
font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
View sticky-div.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.sticky/1.0.3/jquery.sticky.min.js"></script>
<script>
$(function() {
$('div').sticky();
});
</script>
@karlcoelho
karlcoelho / tweet.html
Created Oct 16, 2015
Simple Tweet Button
View tweet.html
<a href="https://twitter.com/share" class="twitter-share-button" data-text="Check this out" data-via="therealcoelho" data-size="large">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
@karlcoelho
karlcoelho / simple-nav.html
Created Oct 9, 2015
Simple Bootstrap Navbar
View simple-nav.html
<nav class="navbar navbar-default">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand</a>
</div>
You can’t perform that action at this time.