Skip to content

Instantly share code, notes, and snippets.

@calebporzio
calebporzio / tinker_helper.php
Created January 30, 2019 23:56
A quick, memorable way to initiate an "artisan tinker" session and play with variables.
<?php
function tinker(...$args) {
// Because there is no way of knowing what variable names
// the caller of this function used with the php run-time,
// we have to get clever. My solution is to peek at the
// stack trace, open up the file that called "tinker()"
// and parse out any variable names, so I can load
// them in the tinker shell and preserve their names.
@calebporzio
calebporzio / chain_helper.php
Last active July 23, 2023 04:27
Handy "chain()" helper method for making non-fluent classes/objects fluent.
<?php
function chain($object)
{
return new class ($object) {
protected $lastReturn = null;
public function __construct($object)
{
$this->wrapped = $object;
@calebporzio
calebporzio / HiddenInput.vue
Created May 2, 2018 14:47
Little Vue component for turning JSON into native HTML for inputs
<script>
import _ from 'lodash'
export default {
props: [ 'name', 'value' ],
methods: {
flatInputsFromDeepJson(item, key, h) {
if (typeof item === 'object') {
return _.flatMapDeep(item, (value, newKey) => {
<template>
<div>
<whoops-message v-if="failed"></whoops-message>
<div v-else>
<component :is="fetchedComponent" v-bind="$props" v-if="loadedHtml"/>
<slot v-else></slot>
</div>
</div>
@nathansmith
nathansmith / center_select.html
Last active February 14, 2024 13:28
Example of how to "center" text in a `<select>` dropdown.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"
/>
<title>
@seyDoggy
seyDoggy / responsive-sticky-footer.css
Last active November 30, 2017 03:04
Responsive sticky footer for bootstrap
@umidjons
umidjons / web-service-soap-client-server-php.md
Last active July 25, 2024 07:45
Simple Web service - SOAP Server/Client in PHP

Simple Web service - SOAP Server/Client in PHP

Implementation of the SOAP server - server.php:

<?php
// turn off WSDL caching
ini_set("soap.wsdl_cache_enabled","0");

// model, which uses in web service functions as parameter
@mako-taco
mako-taco / api.md
Last active June 28, 2018 07:34
Single page app addthis api

#API for single page app use

###addthis.layers.refresh()

  • Updates the share URL of all floating tools (sharing sidebar, for instance) to the current URL
  • Creates inline tools on any elements that do not yet have a tool rendered for it

I can see someone with a single page app doing one of two scenarios:

//always refresh on URL change
@pascaldevink
pascaldevink / scrollspy.js
Created April 13, 2012 20:53
ScrollSpy in pure javascript
/*
Copyright (C) 2021 Pascal de Vink (Tweakers.net)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@kamermans
kamermans / mysql_countries.sql
Created December 7, 2011 04:43
MySQL Dump - continents and countries with 2 and 3 char codes, names and full names - Braintree compatible as of Dec 2011
/**
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------