289 karma · joined April 24, 2013
If you see a script tag with the URL bank.com/evil.js, the browser shouldn't assume that the bank is actually hosting evil.js. Even if the hash matches, the content might not be there.
The bank might be using a content security policy to minimize the damage that an XSS attack can do. It only allows script tags from the same origin. However, now an attacker just needs to load evil.js with a particular hash into the cache, and they can create the illusion that the site is hosting it, without having to hack the server to do so.
1. If the value is 0, output the magic number.
2. If the value has only its high bit set, output 0.
3. Otherwise, shift the value to the left
4. if there was an overflow (the high bit was 1 before the shift), xor the value by a magic constant.
For certain values of the magic constant, this has the property of generating every integer in the range exactly once.
My mindset from the beginning is that I won't work on the project at all after the 24 hours allotted. It's a throw-away project. This is really freeing. You don't have to worry if the code is messy, or even if there is a fundamental problem with your idea (game mechanics, etc.)
My goal is to pick a new technology or library to learn and build something with it. Once, I decided I wanted to learn how to use OpenCV, so I made a little game that is controlled by facial tracking. Another time, I had just bought some USB Nintendo 64 controllers, and I wanted to make a game that used them, so me and some friends made a local multiplayer fighting game. (The projects almost inevitably end up as games). Another project we made a multiplayer game with WebSockets to fiddle with lag compensation and clock synchronization. I learned a ton of distributed systems stuff in that short time. Sometimes, the technical problems take all time, and the finished game just barely counts as playable. Getting OpenCV bindings working with Java took nearly 8 of the 24 hours. Another project, using WebRTC for a peer-to-peer multiplayer game, only came together in the last hour, and stretched the definition of game so much that we won a special award "for challenging perceptions of what games can be" :).
It doesn't really matter, because my goal isn't really to make a great game, it's to force myself out of my comfort zone to learn something new. The game is incidental, really. Sometimes, the judges are looking for something more polished, or more business oriented. That's OK -- the game isn't for those judges. I only invested 24 hours into it. However, I've been pretty lucky, so far -- most hack-a-thons I've been to really celebrate true hacks.
I think one thing organizers can do is emphasize the process of writing the code, rather than the result. Ask what challenges the teams faced, the hardest bug they fixed (or didn't :). Near the beginning, try to offer workshops on different technologies, so that people can branch out and try something new. You can also offer categories of judging -- if there is only one category, it's hard to decide between an awesome business idea with little technical innovation and an awesome technical achievement with little applicability. No matter which one you pick, someone will be disappointed. But if there's a category for best game, best presentation, best app, most innovative, best technical achievement, or whatever categories you pick, then everyone at the hack-a-thon can participate however they like best, and be recognized for it.
One crucial thing to make the GUI simpler than code is direct manipulation. Working with a graphics program, like Inkscape, for example, is much easier for most graphics tasks than writing raw SVGs.
For most tasks in Lyra, you can simply drag-and-drop elements onto the visualization to make it respond the way you want. In advanced cases, true, you do have to navigate menus and buttons. For many of those cases, rather than writing raw D3 code, there's the Vega project. Vega is a declarative format for describing visualizations using a JSON format. Lyra generates Vega specifications for rendering, which can then be modified manually.
Programs such as Honors, AP, electives, etc., are the cheapest way for any student -- regardless of socio-economic background -- to receive high-quality education. Without those programs offered at public schools, I suspect that even more upper-middle class families would transfer to private schools or schools in the suburbs.
Consider sports electives: were they not offered at public schools, the only option would be club programs, often costing thousands per year. At a public school, somewhere around $50 is all that's needed for a year's worth of participation, with coaching that can be comparable to exclusive club teams, and scholarships available for even that amount.
edit: Also, because AP programs are standardized across the country, a student that passes AP Statistics at any school will have the same chance of getting college credit at any school that offers it. This levels the playing field a lot.
Once 1.8 is officially released, someone could create educational adventure maps. I have played some 1.8 maps, and the new features can essentially make Minecraft into a game engine for voxel-based adventure games.
Here's an example from earlier in the 1.8 dev cycle -- there are even more features now. http://www.minecraftmaps.com/adventure-maps/mystery-of-the-t...
For slightly older kids, there's the Minecraft Pi edition.
For example, it let you write text: http://sodaplay.com/creators/russellsprouts/items/font
Some good creators, I'm sure there are many more I'm forgetting:
http://sodaplay.com/creators/mmaarrkkuuss
http://sodaplay.com/creators/edlinfan
http://sodaplay.com/creators/grape
http://sodaplay.com/creators/jeckyll
http://sodaplay.com/creators/im_an_alien
http://sodaplay.com/creators/phider
http://sodaplay.com/creators/lectvay
Many models are made up of motors with legs attached. Here are some interesting ones:
http://sodaplay.com/creators/motors
http://sodaplay.com/creators/other_motors
Also of interest, this paper empirically discovers the physics behind it: http://falcoprof.altervista.org/dispense/sodamathspaperfull....
//Let's define some object
var obj = {a: true, b: true, c: true, d: true, hasOwnProperty: true}
//Now let's make them falsy in different ways
obj.a = undefined; //set to undefined
obj.b = null; //set to null
obj.c = false; //set to false
delete obj.d; //delete key
delete obj.hasOwnProperty //delete key, but present in prototype
console.log(obj.a) //--> undefined
console.log(obj.b) //--> null
console.log(obj.c) //--> false
console.log(obj.d) //--> undefined
console.log(obj.hasOwnProperty) //--> [Function]
console.log('a' in obj) //--> true
console.log('b' in obj) //--> true
console.log('c' in obj) //--> true
console.log('d' in obj) //--> false
console.log('hasOwnProperty' in obj) //--> true
console.log(obj.a == null) //--> true
console.log(obj.b == null) //--> true
console.log(obj.c == null) //--> false
console.log(obj.d == null) //--> true
console.log(obj.hasOwnProperty == null) //--> false
for(var key in obj) {
console.log(key) //--> prints a, b, c
}
In Lua, the only data structure is a hashtable, which maps any non-nil value to any other non-nil value. It can also be set in the objects __index metamethod/table local tab = {a = true, b = true, c = true}
-- by default there are none, but we can defined a fallback metatable similar to a prototype method like js's obj.prototype.hasOwnProperty
setmetatable(tab, {__index={c='meta c', d='meta d'}})
-- if it is important that a key is explicitly set to false, do so, otherwise simply remove it
tab.a = false --set to false
tab.b = nil --set to nil
tab.c = nil --set to nil, present in fallback table
tab.d = false --set to false, present in fallback table
print(tab.a) --false
print(tab.b) --nil
print(tab.c) --meta c
print(tab.d) --false
The rules for Lua are simple: Look for the key in the table, if it's not there, check the fallback defined in the metatable, if not, then return nil.This is especially important in Lua, because any value can be a key, you would have to be sure to delete the key otherwise it could not be garbage collected. local tab1 = {1,2,3,4,5} local tab2 = {} tab2[tab1] = true for k,v in pairs(tab2) do tab[k] = nil end
If this worked like JavaScript, then tab2[tab1] would return nil, but tab1 could not be garbage collected until tab2 is. Because JavaScript objects can only have strings for keys, this is less of an issue.
I like Lua's approach to modules. In Lua, a file is basically equivalent to a function body. It accepts arguments and can return values. In JavaScript, this is not allowed.
In Lua, a function can accept multiple arguments in a tuple called `...`. Every file is implicitly a vararg function, so we can unpack the `...` to get arguments.
> add.lua
local a,b = ...
return a + b
> file.lua
local add = load 'add.lua'
print(add(1,2)) --> 3
load takes a file path and returns that source file as a function.
Most files ignore arguments, but they do return values. > add2.lua
return function(a,b) return a + b end
> file2.lua
local add = require 'add'
print(add(1,2))
`require` loads a source file, executes it, and returns the value that it returns. It is similar to `return load(fileName)()`, but it also has a search mechanism, and caches the result. So, the Lua equivalent of export default is simply returning a value at the end of a source file.The named exports are also easy to replicate. You simply return an object with the keys you want.
> math.lua
return {
add = function(a,b) return a + b end,
sub = function(a,b) return a - b end
}
> other.lua
local math = require 'math'
local add, sub = math.add, math.sub
You can also have something similar to the `export function name(){}` declaration. > hello.lua
local exports = {}
function exports.hello()
print "Hello World"
end
exports.VERSION = '0.0.1'
return exports
> file3.lua
local hello = require'hello'.hello
local version = require'hello'.VERSION
hello() --> Hello World
In all, I think the Lua's require is a much cleaner way to implement modules. Unfortunately, it cannot handle circular references. It may be possible to add this feature using Lua's coroutines, however. I will have to research how it is handled in JavaScript to be sure.The 1.8 update, currently in development, has added features, but it has mostly focused on refactoring and cleaning code. For example, they recently rewrote the entire block id system, removing numerical ids and instead using namespaced identifiers. This will allow mods to coexist rather than try to claim the same block ids.
Example: http://ryanrussell.me/404
setInterval('for(v="visibility",b=document.querySelectorAll("blink"),a=b.length;a--;)c=b[a].style,c[v]=c[v]?"":"hidden"',999)A Monad kind of wraps a certain value. For example, we might have a Promise JSON from an API call. The bind method of a Monad (>>= in Haskell) takes a JSON Promise, and a function (JSON -> Promise b for some b), and returns a value of type Promise b. Promise.then is equivalent to bind.
In Haskell you might define them like this:
data Promise msg val = Resolve val | Reject msg deriving Show
instance Monad (Promise msg) where
return = Resolve
(>>=) :: Promise msg val -> (val -> Promise msg b) -> Promise msg b
(Reject msg) >>= _ = Reject msg
(Resolve val) >>= f = f val
They would be used like this newPromise = jsonPromise >>= transformJSON
In JavaScript, you would write var newPromise = jsonPromise.then(transformJSON)
However, the JavaScript case is slightly different. It is not as strict about types. It is possible (and typical) for transformJSON to return a bare type, rather than a Promise, while Haskell would require a Promise be returned every time. It treats an unwrapped value the same as an already fulfilled promise for that value. But automatically unboxing the promises that are returned gives them the full power of Monads.http://www.w3.org/TR/2011/WD-css3-gcpm-20111129/#footnotes
It adds a float: footnote; property. From reading that page, I believe this might work, once browser support catches up.
a::after {
float: footnote;
content: attr(href) ' "' attr(title) '"';
}
There are some other interesting additions: title {
display: none;
string-set: title content();
}
@page { @top-left { content: string(title) }}
This will put the page title in the top left corner of the page margins. a = {}
a.valueOf = function() {
var caller = arguments.callee.caller.toString();
//parse the caller function, and return
//different values based on what comparison is being made.
}
But I think this is even worse than the getter on the global object.http://www.maa.org/sites/default/files/pdf/devlin/LockhartsL...