Don't use this gist anymore. It has been upgraded to a full github repository
define( | |
['_underscore', 'jquery'], | |
function underscoreExtensions(_, $){ | |
//Object and collection helpers | |
_.mixin({ | |
// Create object from a callback that returns [name, value] pairs. We use this combination a lot | |
// so might as well bake it into the framework | |
mapObject: _.compose(_.object, _.map) |
W:\temp> npm install node-stringprep | |
npm http GET https://registry.npmjs.org/node-stringprep | |
npm http 304 https://registry.npmjs.org/node-stringprep | |
npm http GET https://registry.npmjs.org/nan | |
npm http GET https://registry.npmjs.org/bindings | |
npm http 304 https://registry.npmjs.org/bindings | |
npm http 304 https://registry.npmjs.org/nan | |
> node-stringprep@0.5.2 install W:\temp\node_modules\node-stringprep | |
> node-gyp rebuild |
app.SimpleAuthorization("/Admin/SimpleTableEditor/France/UserPermissions", (owinEnvironment) => | |
Ogre.RoleConfiguration.GetRolesForUser(owinEnvironment["username"].ToString()).Contains("Editor")) | |
//^ Not exactly sure how to do Authorization. Should probably go in its own Nuget package? | |
// My idea is basically just for any request to that route run the lambda, and 401 if it returns false. | |
app.UseSimpleTableEditor(new SimpleTableEditorOptions { | |
Url = "/Admin/SimpleTableEditor/France/UserPermissions", | |
Label = "France - User Permissions", | |
ConnectionString: x => x.ConnectionString( OgreDeployment.ConnectionString("frenchDatamart") ), //Nested closure rather than just interface to make it easier to find | |
//^ or x => x.ConnectionStringName("frenchDatamart") which will pluck the value out of ConfigurationManager |
public class Presentation | |
{ | |
public class PackageResult | |
{ | |
public string Name; | |
public Stream Stream; | |
} | |
//PackageResult as an inner clas can be a good idea since its really just a Tuple and has no reusability value | |
public PackageResult Package() | |
{ |
$tokens = cat .\facebook-tokens.csv | |
pushd | |
$wc = New-Object Net.WebClient | |
mkdir infos | |
cd infos | |
$cntr = 0 | |
foreach($t in $tokens) { | |
$cntr += 1 |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
#code { | |
position: relative; | |
transition: all 1s ease; |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
namespace System | |
{ | |
public static class ObjectExtensions | |
{ |
It works something like this when your db context is injected (and you use AutoMapper)
public IEnumerable<MainScreenSlideDefinition> Get(string type) {
return db.SlideDefinition.Where(s => s.Type == type).ToList().Select(s => Mapper.Map<MainScreenSlideDefinition>(s));
}
or like this if it is not
Last week you learned about objects and how objects are used to group data. Of all the things we've taught you so far its probably least clear how you would use these. I assure you, once you get past very simple websites, you use objects all the time. Let's look at some web applications and identify where the objects might be hiding.
http://content.screencast.com/users/togakangaroo/folders/Jing/media/069877db-54cd-40c6-b468-170187d5882e/2015-05-03_0933.png I'll start with the application I just finished writing. We were building it for two years so I can assure you it's not very simple. It's a web application that helps business analysts generate slide decks that answer questions like "why isn't dairy selling in August". Can you tell where some objects probably are? I worked on it so I can tell you. See each of these slid thumbnails below? Each one has a name, a url to the preview image - remember for images you put in a url into the src attribute, you might have difficulty seeing but it also has the name