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
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
// author: Pawel Kozlowski | |
var myApp = angular.module('myApp', []); | |
//service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" |
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 diagonalTraverse(m, fn) | |
{ | |
// This only works for rectangular or square | |
// form matrices. So no rows of variable sizes! | |
if ( m && m.length > 0 && m[0].length > 0 ) | |
{ | |
var i = 0, j = 0, | |
ci = null, cj = null, | |
M = m[i].length, // # of columns |
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 <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define PI 3.141592653589793 | |
double f_a(double x) { return x*x + sin(x) - PI; } | |
typedef double (*MATH_FUNCTION)(double); |
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
$ gcc -c -g nested_function_segfault.c -ansi -pedantic -O -Wall -Wno-unused-result | |
nested_function_segfault.c: In function ‘polinomi_d’: | |
nested_function_segfault.c:18:5: warning: ISO C forbids nested functions [-pedantic] | |
nested_function_segfault.c: In function ‘main’: | |
nested_function_segfault.c:33:1: warning: control reaches end of non-void function [-Wreturn-type] | |
$ gcc nested_function_segfault.o -o nested_function_segfault.exe -lm | |
$ ./nested_function_segfault.exe | |
Segmentation fault (core dumped) |
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
A LGO R I S M I C A | |
A V A N Ç A D A | |
1 1 1 0 0 1 _ 0 1 | |
_ _ _ _ 0 0 1 _ _ | |
_ _ 1 1 1 _ _ _ _ | |
1 1 1 1 1 1 1 0 1 | |
1 1 1 1 0 0 0 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
//http://zef.me/3420/async-foreach-in-javascript | |
function asyncParForEach(array, fn, callback) { | |
var completed = 0; | |
if(array.length === 0) { | |
callback(); // done immediately | |
} | |
var len = array.length; | |
for(var i = 0; i < len; i++) { | |
fn(array[i], function() { |
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
/** | |
* @author Brian Nettleton | |
*/ | |
class GenericObjectDeserializer implements JsonDeserializer<Object> | |
{ | |
@Override | |
public Object deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException | |
{ | |
if( json.isJsonNull() ) { |
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 makeplain(strAccents) | |
{ | |
if(strAccents==undefined) | |
return ""; | |
strAccents = strAccents.split(''); | |
var strAccentsOut = new Array(); | |
var strAccentsLen = strAccents.length; | |
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
var accentsOut = ['A','A','A','A','A','A','a','a','a','a','a','a','O','O','O','O','O','O','O','o','o','o','o','o','o','E','E','E','E','e','e','e','e','e','C','c','D','I','I','I','I','i','i','i','i','U','U','U','U','u','u','u','u','N','n','S','s','Y','y','y','Z','z']; |
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
// Found at http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454 | |
// | |
// But beware, HTML cannot be regexed... The end is nigh. | |
var re = /<([a-z]+) *[^/]*?>/g; |
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
A = | |
1.000000000000e-01 1.000000000000e-01 1.000000000000e+00 | |
-3.900000000000e+00 1.100000000000e+00 3.200000000000e+00 | |
1.400000000000e+00 1.500000000000e+00 -1.000000000000e+00 | |
c = ( 1.000000000000e-01 1.100000000000e+00 -1.400000000000e+00 ) | |
k = 0 | |
SWAP F0 <=> F1 | |
A = |