Skip to content

Instantly share code, notes, and snippets.

@brihernandez
brihernandez / FreelancerShipPhysics.cs
Last active August 11, 2023 03:51
Freelancer ship physics for Unity. Includes engine kill and thruster.
// ====================================================================================================
// In my codebase, all ships have their own instance of this that they use to apply physics with.
// I'm using a struct mostly because I want to maintain copy semantics.
// ====================================================================================================
public struct FlightInput
{
public float Pitch;
public float Yaw;
public float Roll;
@zaxbux
zaxbux / winter-cms-ajax-readme.md
Created April 13, 2021 08:20
Winter CMS AJAX Framework

Winter AJAX Framework

This is some basic documentation on how the Winter CMS AJAX framework currently works.

Headers

Name Purpose Values
X-Requested-With Tells Winter/Laravel/Symfony that the request is an "AJAX Request". XMLHttpRequest
X-WINTER-REQUEST-HANDLER Tells Winter which AJAX handler method to use on the controller/component. modules/backend/classes/Controller.php#L435 Component handler: component::onEvent; Generic handler: onEvent (Note: the onAjax handler name will always return null)
@jweinst1
jweinst1 / get_unix_time_insecs.rs
Created May 1, 2019 06:55
Using rust to get the unix time in seconds as a number.
use std::time::{SystemTime};
fn get_sys_time_in_secs() -> u64 {
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Ok(n) => n.as_secs(),
Err(_) => panic!("SystemTime before UNIX EPOCH!"),
}
}
@AntonFriberg
AntonFriberg / Dockerfile
Last active July 10, 2023 08:50
Simple docker cron sidecar container based on alpine image
FROM alpine:3.8
# Alpine comes with built in cron schedules
# min hour day month weekday command
# */15 * * * * run-parts /etc/periodic/15min
# 0 * * * * run-parts /etc/periodic/hourly
# 0 2 * * * run-parts /etc/periodic/daily
# 0 3 * * 6 run-parts /etc/periodic/weekly
# 0 5 1 * * run-parts /etc/periodic/monthly
@dunglas
dunglas / example.php
Created April 19, 2018 06:25
A minimalist GraphQL client for PHP
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
@azizur
azizur / Creating a static copy of a dynamic website.md
Last active July 9, 2024 03:00
Creating a static copy of a dynamic website

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
@hereswhatidid
hereswhatidid / archive-commit.bat
Last active November 25, 2022 03:55
Create a zip archive of a specific commit. The archive will be named deploy/deploy-COMMITID.zip.
setlocal enabledelayedexpansion
set var=%1
set output=
for /f "delims=" %%a in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%a" )
git archive -o update-%var:~0,7%.zip HEAD %output%
endlocal
@Kostanos
Kostanos / json-to-csv.php
Created May 24, 2013 03:28
Convert JSON array file to CSV. Use the array keys as the first row. Command line using: json-to-csv.php json.filename > csv.filename
#!/usr/bin/php
<?php
/*
* Convert JSON file to CSV and output it.
*
* JSON should be an array of objects, dictionaries with simple data structure
* and the same keys in each object.
* The order of keys it took from the first element.
*
* Example: