Skip to content

Instantly share code, notes, and snippets.

@schnabear
schnabear / CompositeKey.php
Created September 10, 2019 08:51
Laravel Composite Key Trait
<?php
namespace App\Models\Traits;
use Illuminate\Database\Eloquent\Builder;
trait CompositeKey
{
/**
* Get the value indicating whether the IDs are incrementing.
@schnabear
schnabear / updateBadge.html
Created December 5, 2018 09:15
updateBadge HTML
<!DOCTYPE html>
<html>
<head>
<title>updateBadge</title>
<script>
function updateBadgeCount() {
var badgeCountEl = document.querySelector('#badgeCount');
var customLocation = "native://updateBadge?count=" + badgeCountEl.value;
console.log(customLocation);
document.location.href = customLocation;
@schnabear
schnabear / marker.html
Last active October 26, 2018 02:01
OSM Leaflet
<!DOCTYPE html>
<html>
<head>
<title>OSM</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<style>
html, body {
height: 100%;
margin: 0;
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
@schnabear
schnabear / ubi30.html
Created November 29, 2016 04:30
UBI30 Giveaway
<!DOCTYPE html>
<html>
<body>
<script>
var totalGiveaway = 30;
var totalLoaded = 0;
var body = document.querySelector('body');
for (var i = 1; i <= totalGiveaway; i++) {
var source = 'https://30days.ubi.com/Promotion/RedeemCode/?giveAwayId=giveaway';
if (i > 1) {
@schnabear
schnabear / request.php
Created November 15, 2016 08:02
PUT GET PHP
<?php
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
// $_SERVER['QUERY_STRING']
echo $_GET['foo'];
echo $_GET['bar'];
} elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
parse_str(file_get_contents("php://input"), $_PUT);
echo $_PUT['foo'];
echo $_PUT['bar'];
@schnabear
schnabear / verify_apple_receipt.php
Created September 21, 2016 05:53
PHP Apple Receipt Verification Function
<?php
// http://stackoverflow.com/questions/19785803/validating-appreceiptstoreurl-returning-21002-status
// http://stackoverflow.com/questions/19222845/ios7-receipts-not-validating-at-sandbox-error-21002-java-lang-illegalargume
function verify_curl($base64receipt, $sandbox = false)
{
if ($sandbox) {
$url = 'https://sandbox.itunes.apple.com/verifyReceipt';
} else {
@schnabear
schnabear / export-chat.js
Last active February 13, 2023 02:24
ChatWork Export Chat
var output = '';
function toYMDHMS(timestamp) {
var a = new Date(timestamp * 1000);
var year = a.getFullYear();
var month = ('0' + (a.getMonth() + 1)).slice(-2);
var date = ('0' + a.getDate()).slice(-2);
var hour = a.getHours();
var minute = a.getMinutes();
var second = a.getSeconds();
return year + '/' + month + '/' + date + ' ' + hour + ':' + minute + ':' + second;
@schnabear
schnabear / git-mass-merge.py
Last active October 11, 2018 07:58
Git Mass Merge
#!/usr/bin/env python
import argparse
import subprocess
def main():
parser = argparse.ArgumentParser(description='Git Mass Merge')
parser.add_argument('-p', type=str, required=True, dest='parent_branch')
parser.add_argument('-c', type=str, required=True, dest='child_branch', nargs='+')
parser.add_argument('-u', action='store_true', default=False, dest='is_update_upstream')
@schnabear
schnabear / cheatsheet.txt
Created June 28, 2015 07:46
CIDR SUBNET MASK CHEATSHEET & ICMP TYPE CODES
Netmask Netmask (binary) CIDR Notes
_____________________________________________________________________________
255.255.255.255 11111111.11111111.11111111.11111111 /32 Host (single addr)
255.255.255.254 11111111.11111111.11111111.11111110 /31 Unuseable
255.255.255.252 11111111.11111111.11111111.11111100 /30 2 useable
255.255.255.248 11111111.11111111.11111111.11111000 /29 6 useable
255.255.255.240 11111111.11111111.11111111.11110000 /28 14 useable
255.255.255.224 11111111.11111111.11111111.11100000 /27 30 useable
255.255.255.192 11111111.11111111.11111111.11000000 /26 62 useable
255.255.255.128 11111111.11111111.11111111.10000000 /25 126 useable