Skip to content

Instantly share code, notes, and snippets.

View mladen's full-sized avatar
🌄
Dreaming about mountains and highlands.

Mladen Krivaćević mladen

🌄
Dreaming about mountains and highlands.
View GitHub Profile
@csknk
csknk / Cors.php
Last active December 6, 2019 08:30
Set up CORS on a Laravel API to respond to an Axios request with an 'OPTIONS' preflight.
<?php
// app/Http/Middleware/Cors.php
// It's possible to generate the file with artisan (see comment)
namespace App\Http\Middleware;
use Closure;
class Cors
{
@JacobBennett
JacobBennett / blog.md
Last active June 7, 2024 17:42
Clean up your Vue modules with ES6 Arrow Functions

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({

Let's solve the following physics problem using Symbolism, a computer algebra library for C#.

One strategy in a snowball fight is to throw a first snowball at a high angle over level ground. While your opponent is watching the first one, you throw a second one at a low angle and timed to arrive at your opponent before or at the same time as the first one.

Assume both snowballs are thrown with a speed of 25.0 m/s.

The first one is thrown at an angle of 70.0° with respect to the horizontal.

@wpscholar
wpscholar / vagrant-cheat-sheet.md
Last active June 20, 2024 09:46
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@xem
xem / codegolf.md
Last active June 8, 2024 22:28
JS code golfing

codegolf JS

Mini projects by Maxime Euzière (xem), subzey, Martin Kleppe (aemkei), Mathieu Henri (p01), Litterallylara, Tommy Hodgins (innovati), Veu(beke), Anders Kaare, Keith Clark, Addy Osmani, bburky, rlauck, cmoreau, maettig, thiemowmde, ilesinge, adlq, solinca, xen_the,...

(For more info and other projects, visit http://xem.github.io)

(Official Slack room: http://jsgolf.club / join us on http://register.jsgolf.club)

@gilly3
gilly3 / formatDate.js
Last active August 31, 2020 15:44
JavaScript date formatting function, loosely based on .Net's `String.Format()` for `DateTime`.
export default function formatDate(date, format, utc)
{
var MMMM = ["\x00", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var MMM = ["\x01", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var dddd = ["\x02", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var ddd = ["\x03", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
function ii(i, len) { var s = i + ""; len = len || 2; while (s.length < len) s = "0" + s; return s; }
var y = utc ? date.getUTCFullYear() : date.getFullYear();
format = format.replace(/(^|[^\\])yyyy+/g, "$1" + y);

Zero to Database with Laravel

Part 1: Seeding and Viewing

[Laravel][] is a PHP framework that's really a joy to work with -- though I did find the initial learning curve a bit steep.

This tutorial describes a minimum set of steps necessary to pull content from a database and dump it to a url using Laravel's Eloquent ORM. For me, that was the breakthrough moment.

Assuming you've got [Laravel installed][install] and the [database configured][configure], here are the steps needed to get your data from the database into a web browser:

  1. Create a migration
@hofmannsven
hofmannsven / README.md
Last active June 17, 2024 10:34
Git CLI Cheatsheet
@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption