This file contains hidden or 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
| public class ObjectWaitNotifyExample { | |
| private static final long SLEEP_INTERVAL_MS = 1000; | |
| private boolean running = true; | |
| private Thread thread; | |
| public void start() { | |
| print("Inside start()..."); | |
| thread = new Thread(new Runnable() { | |
| @Override | |
| public void run() { |
This file contains hidden or 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 a = 10; | |
| function add() { | |
| var b = 20; | |
| return a + b; // a is bound to the global a when the function object add() is created. | |
| } | |
| // call add() -> 30 | |
| (function() { | |
| var a = 20; |
This file contains hidden or 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
| mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]' |
This file contains hidden or 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
| public static boolean[][] deepCopy(boolean[][] original) { | |
| if (original == null) { | |
| return null; | |
| } | |
| final boolean[][] result = new boolean[original.length][]; | |
| for (int i = 0; i < original.length; i++) { | |
| result[i] = Arrays.copyOf(original[i], original[i].length); | |
| // For Java versions prior to Java 6 use the next: | |
| // System.arraycopy(original[i], 0, result[i], 0, original[i].length); |
This file contains hidden or 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
| # Homebrew | |
| brew update | |
| brew install p7zip | |
| # Macport | |
| sudo port install p7zip |
This file contains hidden or 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
| // Clear all the nodes inside the element with id 'main-area' | |
| function clearView() { | |
| var mainArea = document.getElementById('main-area'); | |
| var firstChild = mainArea.firstChild; | |
| while (firstChild) { | |
| mainArea.removeChild(firstChild); | |
| firstChild = mainArea.firstChild; | |
| } | |
| } |
This file contains hidden or 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 startTime = process.hrtime(); | |
| //... | |
| let diff = process.hrtime(startTime); | |
| console.log('benchmark took %d nanoseconds', diff[0] * 1e9 + diff[1]); |
This file contains hidden or 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
| // To send events to particular window you can use webContents.send(EVENT_NAME, ARGS) (see docs). webContents is a property of a window instance: | |
| // main process | |
| storeWindow.webContents.send('store-data', store); | |
| // To listen for this event being sent, you need a listener in a window process (renderer): | |
| // renderer process | |
| // ipcRenderer is provided by electron package. You can import it like this: var ipcRenderer = require('electron').ipcRenderer; or es6 import { ipcRenderer } from 'electron'; | |
| import { ipcRenderer } from 'electron'; | |
| ipcRenderer.on('store-data', function (store) { |
This file contains hidden or 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
| // vim: syntax=javascript | |
| const { app, BrowserWindow } = require('electron'); | |
| const path = require('path'); | |
| const Store = require('./store.js'); | |
| let mainWindow; //do this so that the window object doesn't get GC'd | |
| // First instantiate the class | |
| const store = new Store({ | |
| // We'll call our data file 'user-preferences' |
This file contains hidden or 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 fs = require('fs'); | |
| var dir = './tmp'; | |
| if (!fs.existsSync(dir)){ | |
| fs.mkdirSync(dir); | |
| } |