Skip to content

Instantly share code, notes, and snippets.

View ronnyhaase's full-sized avatar
:octocat:
¯\_(ツ)_/¯

Ronny Haase ronnyhaase

:octocat:
¯\_(ツ)_/¯
View GitHub Profile
@ronnyhaase
ronnyhaase / index.js
Created May 1, 2024 21:46
16-Bit Solana Logo - Raffle
const collectionAddress = "HXbJbA5CEzJhYoMH1kmiDGHwZFZyJMGqDXvXqHGQNenW";
const myself = "rnywTUFMTv9KbMoMXYwHKkeYjHBwffnAh9RVE8YkG1d";
(async function main() {
const headers = new Headers();
headers.append("x-api-key", "<Shyft API Key>");
const requestOptions = {
method: "GET",
headers,
@ronnyhaase
ronnyhaase / keybase.md
Created October 19, 2018 12:45
keybase.md

Keybase proof

I hereby claim:

  • I am ronnyhaase on github.
  • I am ronnyhaase (https://keybase.io/ronnyhaase) on keybase.
  • I have a public key ASCCjZFIBM3087qvg29FW789_RmpWB9KSQXkpezRLWKJjwo

To claim this, I am signing this object:

@ronnyhaase
ronnyhaase / dimensions-passer.js
Created August 24, 2018 11:50
A React component passing it's width and height to it's children
// Passes it's width and height to it's children
//
// Does *not* care for resize, since this event is only fired by root element.
// Could either listen to itself, or get notified by a provider to reduce
// listeners
class DimensionPasser extends Component {
constructor(props) {
super(props)
this.state = { parentWidth: 0, parentHeight: 0 }
@ronnyhaase
ronnyhaase / toggleEvent.js
Last active August 29, 2015 14:20
Firing / Toggling DOM events natively
function toggleEvent(element, event, bubbles, cancelable) {
var evType,
ev;
if ( bubbles !== false ) bubbles = true;
if ( cancelable !== false ) cancelable = true;
// Good browser
if ( element.dispatchEvent !== undefined ) {
evType = typeof Event;
@ronnyhaase
ronnyhaase / jquery.httpverbs.js
Last active August 29, 2015 14:15
Extend jQuery AJAX shorthand methods by missing HTTP verbs
jQuery.each(['put', 'delete', 'options'], function(i, method) {
jQuery[method] = function(url, data, callback, type) {
// Shift arguments if data argument was omitted
if ( jQuery.isFunction(data) ) {
type = type || callback;
callback = data;
data = undefined;
}
// The url can be an options object (which then must have .url)
function isString(obj) {
return Object.prototype.toString.call(obj) === "[object String]";
}
@ronnyhaase
ronnyhaase / isAtElementBottom.js
Created January 14, 2014 12:20
Tests if scroll position is at an elements bottom (uses jQuery)
function isAtContainerBottom(el) {
var
$window = $(window),
$el = $(el),
viewTop = $window.scrollTop(),
viewBottom = (viewTop + $window.height()),
containerBottom = Math.floor( $el.offset().top + $el.height() ),
// amount of pre-bottom space to take into account
scrollBuffer = 150;
@ronnyhaase
ronnyhaase / retina.js
Last active December 15, 2015 10:19
JavaScript function that tests for "Retina" screen (pixel ratio > 1.92). Note that there are also high-resolution devices that not necessarily fit (pixel ratio > 1 < 2) !
function isRetina() {
//
// The easy way, a handy little property in the global scope
//
if ( 'devicePixelRatio' in window )
return window.devicePixelRatio >= 1.92;
//
// The hard way, via Media Queries
//
@ronnyhaase
ronnyhaase / formatTime.js
Last active October 10, 2015 15:47
Format time by hour of the day and minute of the hour
/**
* Returns formatted time depending on the clock (e.g. 00:00 / 12:00am)
* @param {number} hour - The hour of the day (0-24)
* @param {number} minute - The minute of the the hour (0-59)
* @param {string} clock - Either "12h" or "24h"
* @returns The time as a well formated string or false in case of an error
*/
function formatTime(hour, minute, clock) {
( minute < 10 )
? minute = '0' + minute
@ronnyhaase
ronnyhaase / dabblet.css
Last active October 4, 2015 20:18
My Logo Animation - Pure CSS (unfinished)
/**
* My Logo Animation - Pure CSS (unfinished)
* View in dabblet: http://dabblet.com/gist/2693201
*/
* {
box-sizing: border-box;
}
html {
background: #e2e2e2 url(http://subtlepatterns.com/patterns/wood_pattern.png);