Skip to content

Instantly share code, notes, and snippets.

package react
import scala.annotation.implicitNotFound
import scala.util.NotGiven
object Domain {
sealed trait Observable[T] {
def observe(op: => T): Unit
}
}
@oscar-broman
oscar-broman / .el
Last active August 18, 2016 13:17
quickly change indentation in spacemacs
;; Put inside dotspacemacs/user-config
(defun set-tab-width (n)
(dolist (var '(evil-shift-width
default-tab-width
tab-width
c-basic-offset
cmake-tab-width
coffee-tab-width
cperl-indent-level
#include <a_samp>
// Enclose statement
#define ENC: \
(_:E1:E2:E3:E4:E5:E6:E7:E8:E9:E10:E11:E12:E13:E14:E15:E16:E17:E18:0,
#define ENC_END: \
)
#define E1:E2:E3:E4:E5:E6:E7:E8:E9:E10:E11:E12:E13:E14:E15:E16:E17:E18:0,%1\32;%2 ENC_2:%1 ENC_END:
switch (weaponid) {
// The spas shotguns shoot 8 bullets, each inflicting 4.95 damage
case WEAPON_SHOTGSPA: {
bullets = amount / 4.950000286102294921875;
if (8.0 - bullets < -0.05) {
return WC_INVALID_DAMAGE;
}
}
@oscar-broman
oscar-broman / db-errors.inc
Last active December 24, 2015 21:39
db_query error reporting
#include <a_samp>
#tryinclude "amx_assembly\amx_header"
#if !defined _inc_amx_header
#error amx_assembly is required. Get it here: github.com/zeex/amx_assembly
#endif
#include "amx_assembly\dynamic_call"
#include "amx_assembly\phys_memory"
@oscar-broman
oscar-broman / free-port.js
Created May 26, 2013 12:14
Find a free port in Node.js
/*
Much better approach than trying to connect to a range of ports.
*/
var net = require('net');
getFreePort(function(err, port) {
if (err) throw err;
console.log('Port: ' + port);
@oscar-broman
oscar-broman / gist:4545758
Created January 16, 2013 09:13
Fetch MySQLi results properly typed.
<?php
function mysqli_fetch_all_typed($result, $resulttype = MYSQLI_NUM)
{
if (!$result)
return null;
$fields = $result->fetch_fields();
if (method_exists($result, 'fetch_all')) {
$rows = $result->fetch_all($resulttype);
@oscar-broman
oscar-broman / gist:3653399
Created September 6, 2012 09:05
UTF8 encode array/object structure in PHP
<?php
function utf8_encode_deep(&$input) {
if (is_string($input)) {
$input = utf8_encode($input);
} else if (is_array($input)) {
foreach ($input as &$value) {
utf8_encode_deep($value);
}
unset($value);

Built-in modules

PBP comes with a few modules by default. These are not mandatory in any way, you can simply remove those you don't need.

Core module 

The core module doesn't do much.. yet.

StaticGroups module 

You can declare groups as global variables with the following syntax:

@oscar-broman
oscar-broman / notepad++.php
Created July 14, 2012 22:30
Generate Notepad++ configuration
<?php
// Requires PAWN-Scanner
// Get it here: https://github.com/oscar-broman/PAWN-Scanner
// Include path to scan
define('INCLUDE_PATH', './', 'a_npc.inc');
// Where to save the files
define('PAWN_XML', './PAWN.xml');
define('USER_DEF_LANG', './userDefineLang.xml');