Skip to content

Instantly share code, notes, and snippets.

Avatar

Christos Lytras clytras

View GitHub Profile
View PHP Tokens.md

PHP Token names with values

This is a list of all PHP 8.0 tokens and their represented values in decimal and hexadecimal. The list exists in the php.net site here https://www.php.net/manual/en/tokens.php but there are no values because these values may change for new releases. When writing token parsing code, we need token names and values, and I don't want to dig into the source code to get the values.

Beware that many, if not all values, may be different along version; PHP 7 may not have the same values with PHP 8. Always use the constants, this is just for reference mainly for debugging.

Blog link https://lytrax.io/blog/dev/php-tokens

View php-event-listener-example.php
<?php
// Used in https://github.com/im4aLL/roolith-event
class Event {
private static $events = [];
public static function listen($name, $callback) {
self::$events[$name][] = $callback;
}
View Tabs vs Spaces - Github tabs.c
void MyFunc()
{
short int one = 1,
two = 2,
three = 3,
myBigFatVariableName = 0,
anOtherBigFatVariableName = 1;
if (
!myBigFatVariableName ||
@clytras
clytras / PhpArrayToYaml.php
Created Feb 19, 2021 — forked from ArnaudLigny/PhpArrayToYaml.php
Convert PHP array to YAML
View PhpArrayToYaml.php
#!/usr/local/bin/php
<?php
if (php_sapi_name() !== 'cli') {
return;
}
date_default_timezone_set('Europe/Paris');
require_once 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
try {
@clytras
clytras / Commit Formatting.md
Created Jan 25, 2021 — forked from brianclements/Commit Formatting.md
Angular Commit Format Reference Sheet
View Commit Formatting.md

Commit Message Guidelines

We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the Angular change log.

Commit Message Format

Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:

@clytras
clytras / popcount.c
Created Mar 24, 2020 — forked from kylelk/popcount.c
sqlite extension to calculate population bit count
View popcount.c
/* compile osx
* gcc -bundle -fPIC -O3 -o popcount.dylib popcount.c
* */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1
View gh-pages deploy npm script
"serve": "yarn build",
"build": "parcel index.html --out-dir dist --public-url ./",
"deploy": "git subtree push --prefix dist origin gh-pages",
@clytras
clytras / index.html
Created Dec 6, 2019 — forked from StickyCube/index.html
Electron click through transparency example
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test App</title>
</head>
<style>
html, body {
height: 100%;
@clytras
clytras / Enhance.js
Created Apr 4, 2019 — forked from sebmarkbage/Enhance.js
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@clytras
clytras / .gitignore
Created Mar 27, 2019 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
View .gitignore
node_modules
dist/
yarn.lock
wwwroot