Skip to content

Instantly share code, notes, and snippets.

View 4e4c52's full-sized avatar
🤠
In the West

Nathan Le Ray 4e4c52

🤠
In the West
View GitHub Profile
@4e4c52
4e4c52 / UploadFile.coffee
Created August 25, 2011 13:06
Upload files via AJAX using FormData
UploadFile = (f) ->
xhr = new XMLHttpRequest()
if (xhr.upload)
xhr.open("POST", "/admin/assets.json", true)
xhr.setRequestHeader("X_FILENAME", f.name)
# new_asset is the ID of my <form>
data = new FormData(document.getElementById('new_asset'))
data.append("asset[picture]", f)
xhr.send(data)
@4e4c52
4e4c52 / assets.js.coffee
Created June 29, 2012 12:09
Javascript File Upload
jQuery ->
$('#tutorials').change ->
$('#asset_chapter_id').after('<span id="loader">&nbsp;<img src="/assets/icons/loader.gif" alt="#" />&nbsp;Loading chapters...</span>')
tutorial = $(@).val()
$.getJSON '/admin/assets/chapters/' + tutorial + '.json', (data) ->
output = ""
for chapter in data
output += '<option value="' + chapter[1] + '">' + chapter[0] + '</option>'
$('#asset_chapter_id').html('').html(output)
$('#loader').remove()
@4e4c52
4e4c52 / combo_box.html
Created July 12, 2012 12:25
Dropdown filters
<div class='control-group'>
<label class='control-label' for='function'>CSCI</label>
<div class='controls'>
<select id='csci'>
<option></option>
<option value='77e9c955-a790-4dec-b16a-6fb58d4f0239'>Sonobuoy System</option>
</select>
</div>
</div>
<div class='control-group'>
2013-10-22 14:00:19,429 INFO FSServer version 2.1.1 starting
Exception in thread "main" java.lang.RuntimeException: failed to initialize new server: <FError: domain=CryptoKeyErrorDomain; code=-1; description=Illegal key size or default parameters; underlying=java.security.InvalidKeyException: Illegal key size or default parameters>
at com.filosync.fsserver.FSServerMain.main(FSServerMain.java:123)
@4e4c52
4e4c52 / fr.yml
Created November 7, 2013 19:38
Redmine contacts_invoices plugin French translations.
fr:
project_module_contacts_invoices: Factures
label_invoice_plural: Factures
label_invoice: Facture
label_invoice_new: Nouvelle facture
label_invoice_edit: Modifier la facture
label_invoice_status: Statut
label_invoice_status_draft: Devis
label_invoice_status_sent: Envoyée
@4e4c52
4e4c52 / 0_reuse_code.js
Created August 18, 2014 20:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@4e4c52
4e4c52 / javascript_resources.md
Created August 18, 2014 20:41 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@4e4c52
4e4c52 / rails_resources.md
Created August 18, 2014 20:41 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@4e4c52
4e4c52 / css_resources.md
Created August 18, 2014 20:41 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@4e4c52
4e4c52 / iframe.html
Created November 19, 2015 15:17
Iframe aware of its visibility.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Iframe</title>
</head>
<body>
<h2>Iframe Content</h2>
<script>