Skip to content

Instantly share code, notes, and snippets.

View jamesgober's full-sized avatar

James Gober jamesgober

View GitHub Profile
@VideoCarp
VideoCarp / lexing.md
Last active February 26, 2025 23:15
Basics of lexing

Lexing for beginners

This is a guide that should teach you how to perform basic lexing in a functional programing language.
Everything was written in Elixir, but you should be able to follow it if you are using any functional programming language.
Or even an imperative programming language like Python, C or Java.\

What is lexing?

The first question you should ask yourself is, what is lexing? It's the same as tokenising, scanning or lexical analysis.
That might not help you if you haven't heard of these either. Put simply, lexing is the process of breaking down a string
into meaningful units, indepdendent of context.
What a lexer will do is make the following happen:

@fhdalikhan
fhdalikhan / help.php
Created October 23, 2020 08:42
Functions to get current CPU load and memory usage under Windows and Linux.
https://www.php.net/manual/en/function.sys-getloadavg.php#118673
Function to get current CPU load as percentage value under Windows and Linux.
Note: Function is getServerLoad(). It will return a decimal value as percentage of current CPU load or NULL if something went wrong (e. g. insufficient access rights).
<?php
header("Content-Type: text/plain");
@wildiney
wildiney / bearer-token.php
Last active February 11, 2024 18:55
[deprecated] PHP - How to get and set Bearer Token
<?php
/**
* ALERT! There are more than ten years since I wrote the first version (adaptation) of this code with PHP 5.6,
* then I changed my code stack and I couldn't mantain this code anymore. Ten years ago worked like a charm.
* Fell free to test, use, fork, update, etc. and if possible put in the comments how to fix,
* if it doesn't work for you as it is, so other people could find answers.
**/
/**
* Get hearder Authorization
@CodeMyUI
CodeMyUI / css-only-3d-paper-fold-text-effect.markdown
Created November 18, 2017 00:10
CSS only 3D paper fold text effect

CSS only 3D paper fold text effect

Attempt at a paper folding effect with text so that it looks like it's coming off the page.

Not supported in IE, or Firefox. This is using experimental clip-path property.

This pen was made using clip-path specifically for a demo I was making to provide some creative ways you can use clip-path, and pseudo elements with text effects. Inspired by a graphic I found on Design Tuts (https://design.tutsplus.com/tutorials/3d-paper-text-effect--cms-27962)

You can see my other experiments here: http://codepen.io/collection/DamKJW/

@CodeMyUI
CodeMyUI / index.html
Created November 14, 2017 01:52
SVG Text Mask w/ Video Fill
<header>
<video autoplay playsinline muted loop preload poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/oceanshot.jpg">
<source src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/ocean-small.webm" />
<source src="http://thenewcode.com/assets/videos/ocean-small.mp4" />
</video>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 285 80" preserveAspectRatio="xMidYMid slice">
<defs>
<mask id="mask" x="0" y="0" width="100%" height="100%" >
<rect x="0" y="0" width="100%" height="100%" />
<text x="72" y="50">OCEAN</text>
@CodeMyUI
CodeMyUI / index.html
Created May 27, 2017 10:49
Menu App Interface
<!-- Menu App Interface
<!-- Based on a Dribbble shot
<!-- that caught my eye
<!-- http://drbl.in/pWyx
<!-- ---------------------------------- -->
<div class="paper preview-1">
<div class="box">
<div class="bar">
<div class="menu">
@Balamir
Balamir / get_os_and_browser.php
Created October 7, 2016 12:50
PHP: get user os and browser information
<?php
/**
* Kullanicinin kullandigi isletim sistemi bilgisini alir.
*
* @since 2.0
*/
function getOS() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
@gkhays
gkhays / DrawSineWave.html
Last active March 4, 2025 13:49
Oscillating sine wave, including the steps to figuring out how to plot a sine wave
<!DOCTYPE html>
<html>
<head>
<title>Sine Wave</title>
<script type="text/javascript">
function showAxes(ctx,axes) {
var width = ctx.canvas.width;
var height = ctx.canvas.height;
var xMin = 0;
@grexlort
grexlort / phonePrefixCodesWithCountry.php
Last active June 1, 2024 01:45
List of phone prefix codes with country in PHP array format prefix => country +xxx
// data from https://gist.github.com/andyj/7108917
$array = [
'44' => 'UK (+44)',
'1' => 'USA (+1)',
'213' => 'Algeria (+213)',
'376' => 'Andorra (+376)',
'244' => 'Angola (+244)',
'1264' => 'Anguilla (+1264)',
'1268' => 'Antigua & Barbuda (+1268)',
@hjanuschka
hjanuschka / hjtest.c
Created May 8, 2015 19:55
PHP Extension Dynamic Resource
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_hjtest.h"
int resid;