Skip to content

Instantly share code, notes, and snippets.

🤸‍♂
Jumping around

Nikola Ristic rista404

Block or report user

Report or block rista404

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rista404
rista404 / hdup.sh
Created Feb 3, 2019
Shortcut for creating a heroku docker app
View hdup.sh
function hdup() {
if [ "$1" != "" ]
then
heroku apps:create $1 --region eu -s container
echo "build:\n docker:\n web: Dockerfile" > heroku.yml
touch Dockerfile
else
echo "Please provide an app name."
fi
}
@rista404
rista404 / wrap-text-usage.js
Last active Sep 3, 2018
Utility to wrap text in canvas, or to get text sizing info (number of lines, height, positions).
View wrap-text-usage.js
import { wrapText } from './wrap-text'
// Drawing and highlighting words (twitter style)
wrapText({
ctx,
text: text,
x: 0,
y: 0,
maxWidth: 500,
lineHeight: fontSize * 1.2,
View cached-json-fetch.js
// @flow
import cache from 'memory-cache'
import fetch from 'isomorphic-fetch'
const TTL_MILISECONDS: number = 10 * 60 * 1000 // ten minutes
export default async function<T>(url: string, options?: Object): Promise<T> {
const cachedResponse = cache.get(url)
if (cachedResponse) return cachedResponse
@rista404
rista404 / Copy.js
Created May 21, 2018
React wrapper for easy integration with clipboard.js (with Flow annotations)
View Copy.js
// @flow
import * as React from 'react'
import Clipboard, { type ClipboardType } from 'clipboard'
type Props = {
text: string,
onSuccess?: () => any,
children: React.Node,
}
View select_text.js
function selectText(element) {
let range
let selection
if (document.body.createTextRange) {
//ms
range = document.body.createTextRange()
range.moveToElementText(element)
range.select()
} else if (window.getSelection) {
//all others
@rista404
rista404 / colors_codegolf.js
Last active Apr 20, 2018
Some codegolfing I did, along with the progress
View colors_codegolf.js
// random hex
'#'+Math.random().toString(16).slice(-6)
'#'+(~~(Math.random()*0xffffff)).toString(16)
'#'+parseInt(Math.random()*0xffffff).toString(16)
// random rgb
r=_=>(Math.random()*255|0),`rgb(${[r(),r(),r()]})`
// random rgba
r=_=>(Math.random()*255|0),`rgba(${[r(),r(),r()]},1)`
View WithSwipe.js
import React from 'react'
export default class WithSwipe extends React.Component {
xDown = null
yDown = null
handleTouchStart = evt => {
this.xDown = evt.touches[0].clientX
this.yDown = evt.touches[0].clientY
}
View play.json
{
"Working Directory" : "\/Users\/rista\/Projects",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Rows" : 30,
"Ansi 11 Color" : {
@rista404
rista404 / index.html
Created Dec 21, 2016
Funky paint app
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 Canvas</title>
<style>
* {
box-sizing: border-box;
}
html, body {
@rista404
rista404 / profiles.json
Created Apr 6, 2016
Personal .dotfiles
View profiles.json
{
"Profiles": [
{
"Working Directory" : "\/Users\/rista",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0
},
You can’t perform that action at this time.