Skip to content

Instantly share code, notes, and snippets.

@Joncom
Joncom / gist:e8e8d18ebe7fe55c3894
Last active September 11, 2021 00:29
Check if two line segments intersect
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) {
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x;
s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x;
s2_y = p3_y - p2_y;
var s, t;

Git Cheat Sheet

Commands

Getting Started

git init

or

@DarrenN
DarrenN / get-npm-package-version
Last active April 17, 2024 16:57 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@jbraithwaite
jbraithwaite / shipitfile.js
Created August 28, 2015 07:27
Shipit deploy with Slack integration
var pack = require('./package.json');
var request = require('request');
var name = pack.name;
module.exports = function (shipit) {
require('shipit-deploy')(shipit);
var deployTo = '/var/www/FOLDER_TO_DEPLOY_TO';
var deployToCurrent = deployTo + '/current';
var slackWebhookURL = 'SLACK_HOOK_URL';
@blha303
blha303 / compliment.b303.me.py
Last active June 25, 2021 04:41
Gets random comment from /r/gonewild, since they're pretty much all compliments. http://compliment.b303.me Warning: May contain sexual content
#!/usr/bin/env python3
import requests
from flask import *
import random
from apscheduler.schedulers.background import BackgroundScheduler
app = Flask(__name__)
scheduler = BackgroundScheduler()
url = "https://reddit.com/r/gonewild/comments.json?limit=200"
@bruth
bruth / README.md
Last active November 23, 2022 21:54
Postgres push notification

Postgres push triggers

Watch a table for changes and push a notification with a payload describing the change.

Example

In the Postgres shell:

-- Create the functions
@mjul
mjul / 02_nginx_gzip_configuration.config
Last active November 6, 2020 03:29
Enable gzip compression in Elastic Beanstalk Docker nginx proxy (add to .ebextensions folder)
files:
"/etc/nginx/conf.d/gzip.conf":
mode: "644"
owner: "root"
group: "root"
content: |
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
@derrek
derrek / google_play_receipt_verification.md
Last active August 17, 2022 19:34
Google Play/Android Receipt Validation/Verification/Lookup with Ruby

This document outlines setting up google's ruby gem, google-api-client, to verify payloads(receipts) sent to a server from google play in app purchases made via an android app.
This document was written using version 0.9.13.

First you'll need 'owner' access to the google play developer's console that contains the mobile app you wish to verify receipts from.

  • Go to https://play.google.com/apps/publish
  • Click on the mobile app you'd like to set up
  • Click "Settings" on the left click "API access"
  • Below "LINKED PROJECT" link the google play account

Next setup an api account

import React, { Component, PropTypes } from 'react'
import { G, Line, Text } from 'react-native-svg'
import * as d3scale from 'd3-scale'
export default class Axis extends Component {
static propTypes = {
width: PropTypes.number.isRequired,
ticks: PropTypes.number.isRequired,
x: PropTypes.number,
y: PropTypes.number,
@itod
itod / split_keyboards.md
Last active April 28, 2024 19:44
Every "split" mechanical keyboard currently being sold that I know of