Skip to content

Instantly share code, notes, and snippets.

View ochafik's full-sized avatar

Olivier Chafik ochafik

View GitHub Profile
@ochafik
ochafik / functions.js
Last active August 27, 2015 14:30
Experiment on Closure Compiler's function types (behaviour of all '*' vs. unknown '?')
// Run with:
// java -jar compiler.jar --language_in=ECMASCRIPT6_STRICT -O ADVANCED --warning_level VERBOSE functions.js
/**
* @param {function(*)} f1 ERROR
* @param {function(*):*} f2 ERROR
* @param {function(?):*} f3
* @param {function(*):?} f4 ERROR
* @param {function(?):?} f5
* @param {function()} f6 ERROR
@ochafik
ochafik / designer.html
Created October 15, 2014 17:53
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../chart-js/chart-js.html">
<link rel="import" href="../ace-element/ace-element.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
@ochafik
ochafik / proxy_polyfill.js
Last active August 29, 2015 14:08
Poor man's Proxy polyfill
function registerOnLoad(fn) {
var prev = window.onload;
window.onload = !prev ? fn : function() {
var prevResult = prev();
return prevResult instanceof Promise ? prevResult.then(fn) : fn();
};
}
if (!this['Proxy']) {
var PolyfillProxy = function(target, handlers) {
@ochafik
ochafik / async_example.dart
Last active August 29, 2015 14:23
Simple example of async/await transform for Dart's dev_compiler (see https://github.com/dart-lang/dev_compiler/issues/221)
// Run with dart:
// dart async_example.dart
import 'dart:async';
f(g) async {
try {
final value = await g();
return 'Result: ' + (value + 1);
} catch (e) {
if (e == 'rethrow me') throw e;
return 'Caught: ' + e;
@ochafik
ochafik / template.html
Created September 4, 2015 14:15
skygular
<!--
Widget build() {
return new Scaffold(
toolbar: buildToolBar(),
body: buildBody()
);
}
}-->
<paper-scaffold>
<paper-header-panel>
/**
* Gets a property descriptor for a target instance, skipping its class
* and walking up the super-classes hierarchy.
*
* @private
* @param {!Object} target
* @param {!string} name
* @return {!Object.<ObjectPropertyDescriptor>|undefined}
*/
$jscomp.getSuperPropertyDescriptor_ = function(target, name) {
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nativelibs4java</groupId>
<artifactId>javacl-tutorial</artifactId>
<name>JavaCL Tutorial</name>
<url>http://code.google.com/p/javacl/</url>
<version>1.0-beta-6</version>
<packaging>jar</packaging>
// Enable double-precision floating point numbers support.
// Not all platforms / devices support this, so you may have to switch to floats.
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
__kernel void dft(
__global const double2 *in, // complex values input
__global double2 *out, // complex values output
int length, // number of input and output values
int sign) // sign modifier in the exponential :
// 1 for forward transform, -1 for backward.
void dft(
const double *in, // complex values input (packed real and imaginary)
double *out, // complex values output
int length, // number of input and output values
int sign) // sign modifier in the exponential :
// 1 for forward transform, -1 for backward.
{
for (int i = 0; i < length; i++)
{
// Initialize sum and inner arguments
package tutorial;
import com.nativelibs4java.opencl.*;
import java.io.IOException;
/// Auto-generated wrapper around the OpenCL program DiscreteFourierTransformProgram.cl
public class DiscreteFourierTransformProgram extends CLAbstractUserProgram {
public DiscreteFourierTransformProgram(CLContext context) throws IOException {
super(context, readRawSourceForClass(DiscreteFourierTransformProgram.class));
}
public DiscreteFourierTransformProgram(CLProgram program) throws IOException {