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
{-# LANGUAGE ForeignFunctionInterface #-} | |
module Test where | |
import Foreign.C.Types | |
hsfun :: CInt -> IO CInt | |
hsfun x = do | |
putStrLn "Hello from haskell" | |
return (42 * x) | |
hsfoo :: CInt -> IO CInt |
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
// connect() is a function that injects Redux-related props into your component. | |
// You can inject data and callbacks that change that data by dispatching actions. | |
function connect(mapStateToProps, mapDispatchToProps) { | |
// It lets us inject component as the last step so people can use it as a decorator. | |
// Generally you don't need to worry about it. | |
return function (WrappedComponent) { | |
// It returns a component | |
return class extends React.Component { | |
render() { | |
return ( |
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
/** | |
* @constructs Printer | |
*/ | |
function Printer(){}; | |
Printer.prototype = {}; | |
/** | |
* Returns if printer is local or network | |
* @returns {boolean} | |
*/ | |
Printer.prototype.isLocal = function(){return true;}; |
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
// rev10 - https://gist.github.com/Noitidart/30e44f6d88423bf5096e | |
function xhrPromise(aUrlOrFileUri, aOptions={}) { | |
// does an async request | |
// aUrlOrFileUri is either a string of a FileURI such as `OS.Path.toFileURI(OS.Path.join(OS.Constants.Path.desktopDir, 'test.png'));` or a URL such as `http://github.com/wet-boew/wet-boew/archive/master.zip` | |
// :note: When using XMLHttpRequest to access a file:// URL the request.status is not properly set to 200 to indicate success. In such cases, request.readyState == 4, request.status == 0 and request.response will evaluate to true. | |
// Returns a promise | |
// resolves with xhr object | |
// rejects with object holding property "xhr" which holds the xhr object | |
var aOptionsDefaults = { |
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
// JSM for working out which globalproperties can be imported in a specific Firefox version. | |
// https://developer.mozilla.org/en-US/docs/Components.utils.importGlobalProperties | |
// I'm not certain availability always equates to functionality but it probably does | |
// and in any case it's a way to narrow down the more involved test for functionality of each property | |
// Run from browser toolbox scratchpad like: | |
// Components.utils.import("resource://test-importGlobalProperties-addon/test.jsm"); | |
Components.utils.import("resource://gre/modules/devtools/Console.jsm"); |
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 flattenTco = ([first, ...rest], accumulator) => | |
(first === undefined) | |
? accumulator | |
: (Array.isArray(first)) | |
? flattenTco([...first, ...rest]) | |
: flattenTco(rest, accumulator.concat(first)) | |
const flatten = (n) => flattenTco(n, []); | |
console.log(flatten([[1,[2,[[3]]]],4,[5,[[[6]]]]])) |
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 myWorker = { | |
// | |
// Worker initialization | |
// | |
get worker() { | |
if (this._worker) { | |
return this._worker; | |
} | |
// Otherwise, initialize PromiseWorker. | |
// TODO |
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
Cu.import('resource://gre/modules/ctypes.jsm'); | |
var nixtypesInit = function() { | |
// BASIC TYPES (ones that arent equal to something predefined by me) | |
this.ATOM = ctypes.unsigned_long; | |
this.BOOL = ctypes.int; | |
this.CHAR = ctypes.char; | |
this.GDKDRAWABLE = ctypes.StructType('GdkDrawable'); | |
this.GDKWINDOW = ctypes.StructType('GdkWindow'); | |
this.DATA = ctypes.voidptr_t; |
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
atom.commands.add 'atom-text-editor', | |
'editor:scroll-down': -> | |
editor = atom.workspace.getActiveTextEditor() | |
editorElement = atom.views.getView(editor) | |
newScrollTop = editorElement.getScrollTop() + editorElement.getHeight() | |
editorElement.setScrollTop(newScrollTop) | |
'editor:scroll-up': -> | |
editor = atom.workspace.getActiveTextEditor() | |
editorElement = atom.views.getView(editor) |
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 <QEvent> | |
#include <QApplication> | |
// Create a subclass of QApplication so that we can customize what we | |
// do when the operating system sends us an event (such as opening a file) | |
class MyApp : public QApplication | |
{ | |
Q_OBJECT | |