There's currently String.fromCharCode and String.fromCodePoint in EcmaScript to convert a (sequence of) character code(s)/code point(s) to a String, but this only works if the input codes are passed as parameters to these String builtins. So a common pattern in JavaScript to construct a String from the bytes in an ArrayBuffer (that was read from a file or fetched from some server) is to either use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*- | |
* Copyright (c) 2011, Benedikt Meurer <[email protected]> | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* | |
* 1. Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
// Put necessary initialization steps here... | |
// Add imageView overlay with fade out and zoom in animation | |
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.window.frame]; | |
imageView.image = [UIImage imageNamed:@"Default"]; // assuming your splash image is "Default.png" or "[email protected]" | |
[self.window addSubview:imageView]; | |
[self.window bringSubviewToFront:imageView]; | |
[UIView transitionWithView:self.window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ~/bin/ocaml-git-sync.sh: Sync the ~/git/ocaml.git repository with the master | |
# Subversion repository at Inria and upload the changes | |
# to GitHub at bmeurer/ocaml. | |
# Copyright (c) 2011 Benedikt Meurer <[email protected]> | |
# | |
# Repository location | |
GIT_DIR="$HOME/git/ocaml.git" | |
export GIT_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////// | |
// Test framework: | |
// Warmup | |
for (var i = 0; i < 1000; ++i) test(data); | |
function time(test, a) { | |
let startTime = Date.now(); | |
// Using F.p.apply here to prevent inlining, so we can really | |
// just measure the performance of test stand-alone. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fibonacci(num){ | |
var a = 1, b = 0, temp; | |
while (num >= 0){ | |
temp = a; | |
a = a + b; | |
b = temp; | |
--num; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const todo = (state = {}, action) => { | |
switch (action.type) { | |
case 'ADD_TODO': | |
return { | |
id: action.id, | |
text: action.text, | |
completed: false | |
} | |
case 'TOGGLE_TODO': | |
if (state.id !== action.id) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const s1 = todo({}, { | |
type: 'ADD_TODO', | |
id: 1, | |
text: "Finish blog post" | |
}); | |
const s2 = todo(s1, { | |
type: 'TOGGLE_TODO', | |
id: 1 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = {x:1, y:2, z:3}; | |
let b = {}; | |
b.x = 1; | |
b.y = 2; | |
b.z = 3; | |
console.log("a is", a); | |
console.log("b is", b); | |
console.log("a and b have same map:", %HaveSameMap(a, b)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = {x:1, y:2, z:3}; | |
let b = Object.assign({}, a); | |
console.log("a is", a); | |
console.log("b is", b); | |
console.log("a and b have same map:", %HaveSameMap(a, b)); |
OlderNewer