Skip to content

Instantly share code, notes, and snippets.

@fospathi
fospathi / svg_matrix_y_flip.txt
Last active August 15, 2022 23:20
SVG matrix to flip the Y-axis direction
The Y-axis in an SVG document points towards the bottom of the page, that is the Y value increases the further down the page
you go. When positioning items in a maths or physics context however it is more appropriate to have the Y-axis pointing up
the page like a normal coordinate system. We can provide an affine transformation matrix to a g element's transform
attribute that flips the Y-axis for its children.
Let the value of the viewBox attribute of the document's SVG element equal "0 0 w h". Suppose we want a coordinate system
whose origin is at the centre of the viewbox and whose Y-axis points up to the top of the page.
(0, 0)
O_ _ _ _ _ _ _ _\ X (Default SVG coordinate system/frame)
@jhoff
jhoff / README.md
Last active April 1, 2024 07:45
Bash-only Laravel Artisan tab auto-complete

If you are an Oh-my-zsh user, see the Laravel 5 plugin

For the rest of us Bash users, all of the Laravel Artisan autocomplete solutions out there require installing a composer package to get a list of artisan commands. Turns out this isn't really necessary. Simply add the provided code in ~/.bash_profile ( or similarly sourced file ) and you'll get artisan command tab completes on any project on your system.

_artisan()
{
	COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
	COMMANDS=`php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"`
	COMPREPLY=(`compgen -W "$COMMANDS" -- "${COMP_WORDS[COMP_CWORD]}"`)
@Razoxane
Razoxane / laravel_conditional_index_migration.php
Created August 8, 2017 01:35
Laravel - Create Index If Not Exists / Drop Index If Exists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LaravelConditionalIndexMigration extends Migration
{
/**
* Run the migrations.
@raduserbanescu
raduserbanescu / remove-mingw-text-from-git-bash-prompt.md
Last active December 22, 2023 19:38
Remove "MINGW" text from Git Bash prompt and window title

Remove "MINGW" text from Git Bash prompt and window title

Quickly remove the text without having to create a custom prompt.

Edit the file: C:\Program Files\Git\etc\profile.d\git-prompt.sh

 else
        TITLEPREFIX=$MSYSTEM
 fi
@superKalo
superKalo / Sortable.jsx
Last active August 9, 2022 09:31
How to use jQuery UI with React JS? You can use this approach to integrate almost any jQuery plugin! Full details and explanation here: http://stackoverflow.com/a/40350880/1333836
class Sortable extends React.Component {
componentDidMount() {
// Every React component has a function that exposes the
// underlying DOM node that it is wrapping. We can use that
// DOM node, pass it to jQuery and initialize the plugin.
// You'll find that many jQuery plugins follow this same pattern
// and you'll be able to pass the component DOM node to jQuery
// and call the plugin function.
@dcoffey3296
dcoffey3296 / angular-fullstack-redirect.js
Last active September 17, 2019 15:55
Authentication redirect for angular-fullstack yeoman generator
// I figured it out, here are the steps I took to solve this problem. For some reason, Stack Overflow isn't formatting my last 2 code blocks below.
// 1. store the url to return to in a cookie within the '.run()' method of `client/app/app.js`
.run(function ($rootScope, $location, Auth, $cookieStore) {
// Redirect to login if route requires auth and you're not logged in
$rootScope.$on('$stateChangeStart', function (event, next) {
Auth.isLoggedInAsync(function(loggedIn) {
if (next.authenticate && !loggedIn) {
// store the requested url if not logged in
@mandiwise
mandiwise / Count lines in Git repo
Last active May 5, 2024 21:37
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@tijnkooijmans
tijnkooijmans / crc16.c
Created April 17, 2014 12:53
CRC-16/CCITT-FALSE
uint16_t crc16(char* pData, int length)
{
uint8_t i;
uint16_t wCrc = 0xffff;
while (length--) {
wCrc ^= *(unsigned char *)pData++ << 8;
for (i=0; i < 8; i++)
wCrc = wCrc & 0x8000 ? (wCrc << 1) ^ 0x1021 : wCrc << 1;
}
return wCrc & 0xffff;
@atifaziz
atifaziz / XMLModule.bas
Created February 13, 2014 14:57
XML pretty printing in VBA
Function PrettyXML(ByVal Source, Optional ByVal EmitXMLDeclaration As Boolean) As String
Dim Writer As MXXMLWriter, Reader As SAXXMLReader
Set Writer = New MXXMLWriter
Writer.indent = True
Writer.omitXMLDeclaration = Not EmitXMLDeclaration
Set Reader = New SAXXMLReader
Set Reader.contentHandler = Writer
Reader.Parse Source
PrettyXML = Writer.Output
@cmalven
cmalven / index.html
Last active April 27, 2024 10:17
Shortest (useful) HTML5 Document
<!-- http://www.brucelawson.co.uk/2010/a-minimal-html5-document/ -->
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>blah</title>
</head>
<body>
<p>I'm the content</p>