Skip to content

Instantly share code, notes, and snippets.

View Omar-Elrefaei's full-sized avatar

Omar Elrefaei Omar-Elrefaei

View GitHub Profile

Introduction

This proposal aims to define the memory model of Julia and to provide certain guarantees in the presence of data races, both by default and through providing intrinsics to allow the user to specify the level of guarantees required. This should allow native implementation in Julia of simple system primitives (like mutexes), interoperate with native system code, and aim to give generally explainable behaviors without incurring significant performance cost. Additionally, it strives to be general-purpose and yet clear about the user's intent—particularly with respect to ensuring that an atomic-type field is accessed with proper care for synchronization.

The last two points deserve particular attention, as Julia has always provided strong reflection and generic programming capabilities that has not been seen—in this synergy combination—in any other language. Therefore, we want to be careful to observe a distinction between the asymmetries of reading vs. writing that we have felt is often not given

Rob Pike's 5 Rules of Programming

Rule 1.

You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is.

Rule 2.

Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.

Rule 3.

Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)

let bookmarkList = Array.from(document.querySelectorAll('.widget>.vbox'))
.map(e => e.shadowRoot)
.map(e => e && e.querySelector('.device-page-list'))
.find(e => e);
let bookmarks = Array.from(bookmarkList.querySelectorAll('.vbox'))
.map(e => `<a href="${e.querySelector('x-link').innerHTML}">${e.querySelector('.device-page-title').innerHTML}</a>`);
copy('<html><body>' + bookmarks.join('\n') + '</body></html>');
@mapa17
mapa17 / pyexcelerate_to_excel.py
Created September 4, 2018 19:46
A helper function to write pandas.DataFrame to excel using pyexcelerate
import pandas as pd
import numpy as np
import timeit
import pyexcelerate
def pyexecelerate_to_excel(workbook_or_filename, df, sheet_name='Sheet1', origin=(1,1), columns=True, index=False):
"""
Write DataFrame to excel file using pyexelerate library
"""

RegEx

Online Regex Tester Suites & Code Generators

  • regex101 Online regex tester for PHP, PCRE, JavaScript and Python that highlights pattern and matches on the fly. Also features a code generator and a regex debugger!
  • myregextester Sports a separate regex split tester and allows to optimize patterns (I guess this is based on Perl's Regexp::Optimizer module).
  • regexr Online regex tester with good regex replace and explain functionality.
  • debuggex Shows neat expression diagrams (not active anymore).
  • regexper translates regular expressions into an SVG image (for documentation or embedding)
  • RexV2 Evaluator for PHP PCRE, PHP Posix!, Perl, Python, Javascript, Node.JS!
@jarcode-foss
jarcode-foss / lua_external.c
Created January 9, 2018 00:05
MPD client code with plain Lua and C
/* GIST NOTE: this is part of a much larger collection of lua utilities for AwesomeWM
and has some (very tiny) lua code that wraps these C functions and places them into
a table. */
/* License: GPLv3
Copyright 2018 Levi Webb */
/* MINIMAL TCP SOCKET SUPPORT */
typedef struct tsoc_con {
@max-mapper
max-mapper / bibtex.png
Last active November 6, 2024 09:03
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
@franz-josef-kaiser
franz-josef-kaiser / nano-shorts.md
Last active January 17, 2025 16:48
nano keyboard shortcuts

^ = Ctrl key M = Alt key

^G      (F1)            Display this help text
^X      (F2)            Close the current file buffer / Exit from nano
^O      (F3)            Write the current file to disk
^J      (F4)            Justify the current paragraph

^R      (F5)            Insert another file into the current one
@brool
brool / yvfc.py
Created January 26, 2012 00:08
Statementless Python -- originally at http://www.pick.ucam.org/~ptc24/yvfc.html
#!/usr/bin/env python
# Look! It's Statementless Python
# Copyright Peter Corbett 2005
# NO WARRANTY: If you use this for anything important, you're mad!
# Credits to: Ian Jackson for having the idea, Ken Slonneger for
# "Syntax and Semantics of Programming Languages" (large parts this program
# were hand-translated from one of the examples), and fanf, with whom I
# cannot hope to compete.
# Unlike most Python programs, whitespace matters little here. It could
# be a one-liner if you had a monitor long enough.