Skip to content

Instantly share code, notes, and snippets.

View christoshrousis's full-sized avatar
💭
beep boop

Christos Hrousis christoshrousis

💭
beep boop
View GitHub Profile
@christoshrousis
christoshrousis / machine.js
Last active November 6, 2020 06:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@christoshrousis
christoshrousis / main.sass
Last active October 8, 2020 04:09
CSS Pixels to Rem Conversion using Browser Context. SCSS & SASS
// The base fontsize you want to use.
$browser-context: 16
@function rem($pixels, $context: $browser-context)
@if unitless($pixels)
$pixels: $pixels * 1px
@if unitless($context)
$context: $context * 1px
@return $pixels / $context * 1rem
@christoshrousis
christoshrousis / javascriptDateFormatter
Last active August 29, 2015 14:21
Date Functions For Javascript, Week Starts On Monday
formatDate = function(date, pretty) {
var dd = date.getDate();
var mm = date.getMonth()+1; //January is 0!
var yyyy = date.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
@christoshrousis
christoshrousis / gist:ea6b5475c457ae666810
Created April 10, 2015 02:32
Ruby - Check if remote image url is valid
require 'open-uri'
require 'net/http'
def remote_file_exists?(url)
url = URI.parse(url)
Net::HTTP.start(url.host, url.port) do |http|
return http.head(url.request_uri)['Content-Type'].start_with? 'image'
end
end
@christoshrousis
christoshrousis / _navbar.haml
Created May 12, 2014 00:43
Simple Bootstrap Navbar written as a HAML Partial. Useful for Middleman / Sinatra / Ruby on Rails.
.container
#nav{:role => "navigation", :class => "navbar navbar-default"}
.container-fluid
.navbar-header
%button{:class => "navbar-toggle", :type => "button", :'data-toggle' => "collapse", :'data-target' => "#bs-example-navbar-collapse-1"}
%span{:class => "sr-only"} Toggle Navigation
%span{:class => "icon-bar"}
%span{:class => "icon-bar"}
%span{:class => "icon-bar"}
%a{:class => "navbar-brand", :href => "/"} Home
@christoshrousis
christoshrousis / layout.haml
Created May 12, 2014 00:25
This is the layout.haml file I use when I want to start with a HTML5 Boilerplate using Middleman. In addition to some basic layout, it includes a CDN version of Bootstrap and jQuery. I have removed the Normalize.css as it is included with Bootstrap and there is no need to re-include it.
!!! 5
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
%head
%meta{:charset => 'utf-8'}
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
%title
= current_page.data.title || "The Middleman"