Skip to content

Instantly share code, notes, and snippets.

@2bard
2bard / translation_notes
Created December 18, 2012 16:29
Using Symfony translation component in Twig outside of Symfony2 framework.
Note: I've left some of the full package names in tact to show exactly where the class comes from.
#### Pull dependencies in using composer ####
//Example composer.json
{
"require": {
"symfony/config" : "2.1.0",
"symfony/yaml" : "2.1.0",
"twig/twig": "1.9.0",
@tentacode
tentacode / XSDValidator.php
Created July 5, 2013 13:47
Super easy XML/XSD validator (require libxml)
<?php
namespace Tentacode\FilesystemBundle\XML;
use DOMDocument;
use XMLReader;
class XSDValidator
{
protected $xmlFile;
@julienbourdeau
julienbourdeau / wilson.php
Last active August 13, 2024 12:55
[PHP] 5 Star Rating - Lower bound of Wilson score confidence interval for a Bernoulli parameter
<?php
/*
|--------------------------------------------------------------------------
| 5 Star Rating
|--------------------------------------------------------------------------
|
| Lower bound of Wilson score confidence interval for a Bernoulli parameter (0.9604)
|
| See:
@jgautheron
jgautheron / errorHandler.js
Created May 10, 2017 14:52
Send client errors to the server
import ReactUpdates from 'react-dom/lib/ReactUpdates'
import ReactDefaultBatchingStrategy from 'react-dom/lib/ReactDefaultBatchingStrategy'
import 'isomorphic-fetch'
const logError = (err, extra = {}) => {
fetch('/logger', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
version: '3'
services:
redis:
image: redis
container_name: redis
postgres:
image: 'postgres'
container_name: postgres
@thomascube
thomascube / vtimezone.php
Last active February 15, 2023 21:15
VTIMEZONE component for a Olson timezone identifier with daylight transitions.Solution to this StackOverflow question: https://stackoverflow.com/questions/6682304/generating-an-icalender-vtimezone-component-from-phps-timezone-value/25971680
<?php
use \Sabre\VObject;
// use composer autoloader
require_once 'vendor/autoload.php';
/**
* Returns a VTIMEZONE component for a Olson timezone identifier
* with daylight transitions covering the given date range.
@tobywf
tobywf / clean_old_lambda_versions.py
Last active September 9, 2024 17:50
A quick script to remove old AWS Lambda function versions
from __future__ import absolute_import, print_function, unicode_literals
import boto3
def clean_old_lambda_versions():
client = boto3.client('lambda')
functions = client.list_functions()['Functions']
for function in functions:
versions = client.list_versions_by_function(FunctionName=function['FunctionArn'])['Versions']
for version in versions:
@compustar
compustar / hugin_stitch.bat
Last active June 16, 2021 12:49
Batch files for Hugin stitching for Mi Sphere or Madv360 with template (https://github.com/pxlartificer/XiaomiMijiaMi-HuginTemplate).
REM Usage: hugin_stitch.bat template-XiaomiMijiaMiJPG.pto IMG_20171231_172305.jpg
@echo off
SET PATH=%PATH%;C:\Program Files\Hugin\bin
FOR %%i IN ("%2") DO (
SET Name=%%~ni
)
pto_gen %2 %2 --output=%Name%_stitched.pto
@anderly
anderly / FilterMenu.vue
Last active August 16, 2019 16:17
Make Laravel Nova Per Page options configurable both globally and at resource level.
<template>
<dropdown
v-if="filters.length > 0 || softDeletes || !viaResource"
dusk="filter-selector"
class-whitelist="flatpickr-calendar"
>
<dropdown-trigger
slot-scope="{ toggle }"
:handle-click="toggle"
class="bg-30 px-3 border-2 border-30 rounded"
@neilhawkins
neilhawkins / list-of-salutations-titles-honorifics.txt
Last active August 27, 2024 11:21
List of salutations, honorifics, titles, Mr, Mrs, Sir in plain text
Mr
Mrs
Master
Miss
Ms
Mx
Dr
Admiral
Air Comm
Ambassador