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 isBalanced(const string message) { | |
int paransOpen = 0; | |
int maybeOpen = 0; | |
int maybeClosed = 0; | |
char prevChar = 0; | |
string::const_iterator iter; | |
for (iter = message.begin(); iter < message.end(); iter++) { | |
if (*iter == '(') { | |
if (prevChar == ':') { |
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
#include <iostream> | |
#include <cstring> | |
#include <cstdlib> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int lamps, opsToDo; |
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
angular.module('myApp', []).directive('includeIfVisible', function () { | |
function isElementInViewport(el) { | |
var rect = el.getBoundingClientRect(); | |
return ( | |
rect.top <= (window.innerHeight || document.documentElement.clientHeight) && | |
rect.right >= 0 && | |
rect.bottom >= 0 && | |
rect.left <= (window.innerWidth || document.documentElement.clientWidth) | |
); | |
} |
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
var couchUrl = "foobar"; | |
$.getJSON(couch-url + "view-name-here", function(data) { | |
data.rows.forEach(function (doc) { | |
$.ajax({ | |
url: couch-url + doc.value._id + '?rev=' + doc.value._rev, | |
type: 'DELETE', | |
success: function(result) { | |
console.log("Deleted document with id " + doc.value._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
-- Recursion | |
findKey :: (Eq k) => k -> [(k,v)] -> Maybe v | |
findKey key [] = Nothing | |
findKey key ((k,v):xs) = if key == k | |
then Just v | |
else findKey key xs | |
-- Fold | |
findKey :: (Eq k) => k -> [(k,v)] -> Maybe v | |
findKey key = foldr (\(k,v) acc -> if key == k then Just v else acc) Nothin |
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
var validateUser = function(user) { | |
return new Promise(function(resolve, reject) { | |
var validationError = c.validateFields(user, newUserRequiredFields, newUserAllowedFields); | |
if (validationError) { | |
reject(validationError); | |
} else { | |
checkUserExistence(user.username).then(resolve).catch(reject); | |
} | |
}); | |
}; |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2014 Simon Friis Vindum <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2014 Simon Friis Vindum <[email protected]> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
var openRequest = indexedDB.open("library"); | |
openRequest.onupgradeneeded = function() { | |
// The database did not previously exist, so create object stores and indexes. | |
var db = openRequest.result; | |
var store = db.createObjectStore("books", {keyPath: "isbn"}); | |
var titleIndex = store.createIndex("by_title", "title", {unique: true}); | |
var authorIndex = store.createIndex("by_author", "author"); | |
// Populate with initial data. |
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
import GHCJS.DOM.EventM (event, preventDefault) | |
import GHCJS.DOM.Element | |
form :: MonadWidget t m => m a -> m (Event t (), a) | |
form child = do | |
(form, ch) <- el' "form" child | |
submit <- wrapDomEvent (_el_element form) elementOnsubmit (void $ preventDefault) | |
performEvent_ (return () <$ submit) | |
return (submit, ch) |
OlderNewer