Skip to content

Instantly share code, notes, and snippets.

View mrowa44's full-sized avatar

Justyna Rachowicz mrowa44

  • Kraków, Poland
View GitHub Profile
@mrowa44
mrowa44 / read_char.rb
Created April 5, 2015 14:54
Non-stopping input (even special characters, arrows etc.)
require 'io/wait'
def read_char
system "stty raw -echo"
if $stdin.ready?
char = $stdin.getc.chr
if char == "\e"
extra_thread = Thread.new do
char += $stdin.getc.chr
char += $stdin.getc.chr
@mrowa44
mrowa44 / refresh.rb
Last active March 16, 2016 11:15
Refresh Chrome on file save
#!/usr/bin/env ruby
trap('SIGINT') { exit }
if ARGV.length < 2
puts "Usage: #{$0} directory keyword_from_url"
puts "Example: #{$0} ~/Projects/whatever localhost"
exit
end
@mixin theme($prop, $darkcolor, $lightcolor) {
.Dark & {
#{$prop}: #{$darkcolor};
}
.Light & {
#{$prop}: #{$lightcolor};
}
}
function WindowListener(windowEvents, windowHandler, capture = false) {
const events = (typeof windowEvents === 'string') ? [windowEvents] : windowEvents;
const handler = windowHandler || 'forceUpdate';
return {
componentDidMount() {
for (let i = 0; i < events.length; i++) {
window.addEventListener(events[i], this[handler], capture);
}
},
function shouldLoadMore(component, node, offset) {
if (typeof component.needsMoreItems === 'function' && component.needsMoreItems()) {
return true;
} else if (node) {
const rect = node.getBoundingClientRect();
const innerHeight = window.innerHeight;
return rect.top + rect.height > innerHeight && innerHeight > rect.bottom - offset;
}
return false;
}
getHTML() {
let selector = this.props.selector;
let xhr = new XMLHttpRequest();
xhr.open('GET', this.props.from, true);
xhr.onreadystatechange = function() {
if (this.readyState === 4) {
let parser = new DOMParser();
let document = parser.parseFromString(xhr.responseText, 'text/html');
return document.querySelector(selector);
}
#!/bin/bash
protected_branch='develop'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push develop, is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
@mrowa44
mrowa44 / plugins.md
Last active January 17, 2017 16:41
Porting Chrome plugins to Firefox

Plugins are really just a tiny web apps that run in a popup.

To load your local extension in Chrome:

  • open up extensions page by putting chrome://extensions/ in the address bar
  • check developer mode at the top
  • click load unpacked extension and select the folder your extension is in

To load your local extension in Firefox:

  • download and install a Nightly build of Firefox
  • create a new profile for testing and development
ghGetOrganizationMembers(orgName) {
let page = 1;
const members = [];
return new Promise((resolve, reject) => {
const getNextPage = () => {
githubGet(`orgs/${orgName}/members`, { page })
.then(({ data }) => {
if (data.length > 0) {
page++;
@mrowa44
mrowa44 / node-debug.md
Last active March 8, 2017 17:45
debugging node in devtools with live reloading

Prerequisites: Node.js 6.3+, Chrome 55+, nodeamon

  • turn on chrome://flags/#enable-devtools-experiments & relaunch Chrome
  • open devtools settings > experiments, press shift 6 times (lol, for real) and check node debugging box
  • open & close devtools
  • nodemon --watch . --inspect app.js
  • connect to node in devtools (Sources > Threads (on the right) > Connect next to node)

Debugging tests: mocha --debug-brk --inspect --grep 'something' path/to/test.js