Skip to content

Instantly share code, notes, and snippets.

View Lax's full-sized avatar

Liu Lantao Lax

View GitHub Profile
# This is the complete source code to Flappy Dragon:
# https://dragonruby.itch.io/flappydragon
#
# You can tinker with this by getting a copy of DragonRuby Game Toolkit:
# https://dragonruby.org/
#
# Amir Rajan wrote this game, catch him at https://twitter.com/amirrajan !
class FlappyDragon
attr_accessor :grid, :inputs, :game, :outputs
@ersinakinci
ersinakinci / electron-webpack-node-integration-false.md
Last active January 25, 2023 19:03
Making electron-webpack work with nodeIntegration: false

NOTE, April 18, 2020: I wrote this document in February 2019 when I was actively investigating Electron. I haven't used it since then and have largely forgotten what this was for or how electron-webpack works. I vaguely remember the problem, but that's it. It would appear based on the comments below that this document is still coming up in web searches but has become out of date and parts of it don't work. If anyone has specific fixes to my instructions, please leave them in the comments and I'll happily incorporate them.

Using electron-webpack without Node integration

Overview

The current version (as of 2019-02-02) of electron-webpack is set up with the assumption that your BrowserWindow instance has nodeIntegration: true. However, Electron is encouraging users to set nodeIntegration: false as a security precaution, and in the future BrowserWindows will have this setting set to false by default. Doing so now with electron-webpack throws an error because the index.html template has commonjs re

@mrbar42
mrbar42 / README.md
Last active October 25, 2024 19:35
Secured HLS setup with Nginx as media server

Secured HLS setup with Nginx as media server

This example is part of this article.

This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:

  • Domain filtering
  • Referrer filtering
  • Embed buster
@frankrausch
frankrausch / CustomDocumentWindow.swift
Last active September 4, 2018 06:43
Prevent NSPopover from stealing an NSTextField’s focus when using the popover to display live search results. Swift adaption of Wil Shipley’s solution (https://stackoverflow.com/a/21111462)
protocol PopoverFirstResponderStealingSuppression {
var suppressFirstResponderWhenPopoverShows: Bool { get }
}
class CustomDocumentWindow: NSWindow {
override func makeFirstResponder(_ responder: NSResponder?) -> Bool {
if responder != self.firstResponder,
let newFirstResponder = responder as? NSView {
let newFirstResponderWindow = newFirstResponder.window
@rishigesh
rishigesh / gist:fc66a2cb35372b2aa011a7a69f606d40
Created March 17, 2017 15:24
NSImage Flip Horizontally (Swift)
public func flipHorizontally() -> IOSXImage {
let existingImage: NSImage? = self
let existingSize: NSSize? = existingImage?.size
let newSize: NSSize? = NSMakeSize((existingSize?.width)!, (existingSize?.height)!)
let flipedImage = NSImage(size: newSize!)
flipedImage.lockFocus()
let t = NSAffineTransform.init()
t.translateX(by: (existingSize?.width)!, yBy: 0.0)
// Makes the text in an NSTextFieldCell vertically centered. Works with single line, non-editable cells.
// Maybe doesn't work with others.
// Stolen from this stackoverflow question:
// http://stackoverflow.com/questions/1235219/is-there-a-right-way-to-have-nstextfieldcell-draw-vertically-centered-text
import Cocoa
class VerticallyCenteredTextFieldCell: NSTextFieldCell {
override func titleRect(forBounds rect: NSRect) -> NSRect {
@Bhavdip
Bhavdip / sketch-never-ending.md
Created October 6, 2016 15:53
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active September 29, 2024 17:25
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
anonymous
anonymous / config.json
Created March 3, 2015 09:20
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@hay
hay / WMStats.java
Last active August 30, 2016 11:03
Wikipedia statistics parser comparison
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WMStats {
private static final String FILE_NAME = "pagecounts-20141029-230000";