Skip to content

Instantly share code, notes, and snippets.

@tomstorey
tomstorey / z80_malloc.s
Last active March 5, 2024 19:31
malloc and free implementation in Z80 assembly
heap_start .equ 0x9000 ; Starting address of heap
heap_size .equ 0x0100 ; Number of bytes available in heap
.org 0
jp main
.org 0x100
main:
ld HL, 0x8100
@SimonEast
SimonEast / curl_function.php
Last active September 18, 2018 07:39
PHP Curl (The Easy Way)
<?php
/**
* Easy remote HTTP requests using a single function
* (How curl probably SHOULD have been written originally)
*
* If you need something more advanced/robust, use 'guzzle'
* But this function is useful for when you don't need a massive library,
* but rather something simpler and more lightweight
*
* Examples:
@RafalWilinski
RafalWilinski / ionic-repair.sh
Last active May 5, 2017 00:17
Complete solution for repairing your Ionic app
ps aux | grep deploy | tr -s " " | cut -d " " -f2 | xargs kill
ps aux | grep lldb | tr -s " " | cut -d " " -f2 | xargs kill
sudo npm update
sudo npm uninstall cordova ionic ios-sim ios-deploy
sudo npm install -g cordova ionic ios-sim ios-deploy
cordova platform rm ios
cordova platform add ios
ionic prepare ios
ionic state reset
ionic state restore
@cornernote
cornernote / README.md
Created June 4, 2015 12:38
How to use PsySH with a Yii2 application

Using PsySH (GitHub) as the Yii2 shell

  • Issue the following commands from the command line in your Yii application directory:
    • chmod +x psyii
    • mkdir extensions/yiishell
    • wget -O extensions/yiishell/psysh psysh.org/psysh
    • chmod +x extensions/yiishell/psysh
  • Copy the file init.php below to psysh/init.php and update any paths to work with your application configuration
  • Copy the file config.php below to psysh/config.php. Change or add to the config array with the options you'd like to use (available options)
  • Now you can start PsySH with the command ./psyii psysh/init.php --config psysh/config.php
@xeoncross
xeoncross / http_accept_language.php
Last active October 19, 2023 12:46
Parse the HTTP except language header
<?php
function prefered_language($available_languages, $http_accept_language) {
$available_languages = array_flip($available_languages);
$langs = array();
preg_match_all('~([\w-]+)(?:[^,\d]+([\d.]+))?~', strtolower($http_accept_language), $matches, PREG_SET_ORDER);
foreach($matches as $match) {
@jirutka
jirutka / -README.md
Last active October 31, 2023 09:07
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings
@elidickinson
elidickinson / max_width_email.html
Created May 6, 2013 15:10
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@ezzatron
ezzatron / num-cpus.php
Created October 28, 2011 03:53
Function to detect number of CPUs in PHP
<?php
/**
* Copyright © 2011 Erin Millard
*/
/**
* Returns the number of available CPU cores
*
* Should work for Linux, Windows, Mac & BSD