Skip to content

Instantly share code, notes, and snippets.

@cssquirrel
cssquirrel / FileUploadApiController.cs
Last active January 25, 2019 11:49
Using AngularJS API service and Umbraco API controller to permit users to upload files to the server
// Use whatever namespacing works for your project.
namespace YourSite.Web.Controllers.Api
{
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
@cssquirrel
cssquirrel / filter.out.duplicate.objects.example.js
Created May 6, 2015 19:04
Filter out duplicates in an array of objects using Underscore
// bananas is a complex object
bananas = _.uniq(bananas, function(banana) {
return JSON.stringify(banana);
});
// Caveat: order of properties in an object could be jumbled depending on how objects are created
// In such a case, this trick will not work. To prevent this, consider creating objects using a class-like declaration:
var BananaModel = function(data) {
var self = this;
@cssquirrel
cssquirrel / prevent.raw.template.example.html
Created May 7, 2015 23:57
Prevent Flash of Raw Angular Template
<!-- doctype html -->
<html>
<head>
<!-- If not including Angular.js in header, include in CSS -->
<style type="text/css">
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
</style>
</head>
@cssquirrel
cssquirrel / annyang.add-commands-with-dynamic-text.js
Created January 17, 2016 18:29
Alternate function for annyang.js that makes it easier to enter commands with dynamically generated text instead of only literal text strings.
// Insert this into annyang.js to have alternate command functionality
/**
* @method addCommandsWithDynamicText
* @param {array of Object} commands
* @param {string} commands[i].phrase - The speech that annyang is listening for to trigger from.
* @param {function or Object} commands[i].callback - If a function, a callback to trigger if the phrase is heard. If an object, it has a callback parameter (which is the function) and a regexp parameter (which contains an optional regexp string to use for the phrase).
* @description An alternate way to give annyang commands that makes it easier to have variables in your code with dynamically generated strings to pass into the phrase, instead of only allowing text like addCommands()
*/
addCommandsWithDynamicText: function(commands) {
@cssquirrel
cssquirrel / installer.cs
Created January 23, 2017 19:39
Example of creating a custom section in Umbraco
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Xml;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Web;
@cssquirrel
cssquirrel / zoom.area.cropper.value.example.js
Created May 31, 2017 19:44
Sample Zoom Area Cropper Value Output
{
"crops": [{
"x": 2999,
"y": 805,
"width": 400,
"height": 200,
"url": "/media/1050/allez-faire-loutre.jpg?crop=2999,805,400,200&width=400&height=200",
"name": "Crop 1",
"zoom": 1
}, {
@cssquirrel
cssquirrel / react-v16-components.md
Last active January 3, 2018 16:58
React v16 Components

Here's a quick rundown on what's going on with React v16 components.

Suppose that you are calling a Foo component in your React code like so:

  <Foo name="Fred" />

In earlier versions of React, Foo may have looked something like this, using React.createclass().

@cssquirrel
cssquirrel / ernest-example.cshtml
Created February 20, 2018 22:03
A simple example of how to use the Ernest rich text editor in a view.
@inherits UmbracoTemplatePage
<div>
@* Assume we have an Ernest property editor named bodyText on the document type.*@
@Model.Content.GetPropertyValue<IHtmlString>("bodyText")
</div>
@cssquirrel
cssquirrel / how-we-record-stardate-supplemental.md
Last active July 22, 2021 14:28
How We Record Stardate: Supplemental

How We Record Stardate: Supplemental

Equipment and Software

Each of the Brothers Weems records using a Blue Snowball microphone and Audacity audio software. We also have the free LAME encoder which allows Audacity to export to MP3.

Recording Procedure

We're in our own apartments as we record, each recording our own stream while on Skype together. To later make it easier to sync our tracks, one of us plays a loud buzzer while the other holds headphones to their microphone. Once we're done recording, we export our own soundtracks to MP3 format with 128 kbps, stereo, constant rate sounds.

@cssquirrel
cssquirrel / puppies-trying.md
Last active January 22, 2019 16:35
Puppies Trying Their Hardest the RPG