Skip to content

Instantly share code, notes, and snippets.

View 422404's full-sized avatar
💭
Turning O2 into CO2

Elyan Poujol 422404

💭
Turning O2 into CO2
  • The Great Fabric Of The Universe
  • Ȟ̷̢͍̟͙̤͓̫̞̜̍̽̚͠ḙ̴̢͕̦̙̆̿r̷̰̟̺̳̰͇̦̾̇͐̍͑̿͘̚̚͝ͅe̴̛͍̖̪͗̒̋̅̒̇̑̓̉
View GitHub Profile
/**
* Nice annotation instead of putting a comment
* Only for readability purpose
*/
@Target(AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.SOURCE)
private annotation class Provides
/**
* Nice annotation instead of putting a comment
import kotlin.ranges.*
// While
fun whileTrueRepeat(target: () -> Boolean, body: () -> Unit): Unit {
if (target()) {
body()
whileTrueRepeat(target, body)
}
}
@422404
422404 / preventSwipe.md
Last active June 14, 2018 20:56
Prevent opening the side menu by swiping in ExtJS Modern Toolkit

While digging on how to prevent the user to open the side menu by swiping I found nothing. I tried to override the onEdgeSwipe and onSwipeStart methods of Ext.Viewport but nope...

Some tests after, tadaaa ! If I replace the Ext.Viewport.beforeMenuAnimate method with an empty function it prevent the menu opening by swiping... and by calling Ext.Viewport.showMenu(..)

The solution

let oldBeforeMenuAnimate = null;
let noop = function () {};
@422404
422404 / index.ts
Last active June 13, 2018 22:44
Singletonify™ a class using Typescript decorators
import Singleton from './singletonify'
@Singleton()
class MyStrictSingleton {}
@Singleton(false)
class MySingleton {}
console.log('MyStrictSingleton instanciation 1:');
try {
@422404
422404 / dependencyInjection.ts
Created June 13, 2018 21:05
JavaScript Dependency Injection™ using Typescript decorators
/*********************************** Typing ***************************************/
/**
* Signature of a constructible class
*/
interface IClass {
/**
* Used to express the constructability of a class
*/
new(...args: any[]): {};
@422404
422404 / electron_browserwindow_hookwindowmessage.md
Created April 9, 2018 17:59
Electron BrowserWindow hookWindowMessage callback signature

Doc of the function : BrowserWindow's doc

After reading the doc a question remain: "WTF are the callback parameters !?" To answer the question we need to dig into Electron source code and we found that: Native call to callback function

hell yeah the function signature is :

hookWindowMessage(Buffer, Buffer)