Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Glingeanu andreiglingeanu

View GitHub Profile
@andreiglingeanu
andreiglingeanu / snippet.vim
Created Dec 15, 2017
optimize a whole SVG file using SVGO
View snippet.vim
%!svgo -i - -o -
@andreiglingeanu
andreiglingeanu / set-wallpaper.sh
Created Nov 30, 2017 — forked from willurd/ set-wallpaper.sh
Set the Desktop Background for all of your open Spaces in Mountain Lion
View set-wallpaper.sh
read -e IMAGE;
defaults write com.apple.desktop Background "{default = {ImageFilePath='$IMAGE'; };}"
killall Dock
@andreiglingeanu
andreiglingeanu / nullify-transforms.js
Last active Jul 15, 2021
A nice way to nullify CSS transforms and get original positions of the un-modified rect
View nullify-transforms.js
// Nullify the transforms of the element
//
// This is all behaving just like getBoundingClientRect() but it nullifies all the transforms
// and kinds _reverts_ the element onto its original position.
// This will work even with complex translations, rotations.
// The beauty is in the way it applies matrix inverse onto the transformation
// matrix and mutates the getboundingclientrect along the way.
//
// Usage:
// let { top, left } = nullifyTransforms(el);
View .pryrc
# Using these pry gems
# gem "pry"
# gem "pry-rails"
# gem "pry-byebug"
# gem "pry-stack_explorer"
# gem "pry-doc"
# gem "pry-state"
# gem "pry-toys"
# gem "pry-rescue"
@andreiglingeanu
andreiglingeanu / wp-image-crop-position.php
Created Aug 8, 2017 — forked from bradt/wp-image-crop-position.php
WordPress: Set an image's crop position and rotates images based on EXIF information if necessary
View wp-image-crop-position.php
<?php
/* Example Usage:
* bt_add_image_size( 'product-screenshot', 300, 300, array( 'left', 'top' ) );
* bt_add_image_size( 'product-feature', 460, 345, array( 'center', 'top' ) );
*/
add_filter( 'intermediate_image_sizes_advanced', 'bt_intermediate_image_sizes_advanced' );
add_filter( 'wp_generate_attachment_metadata', 'bt_generate_attachment_metadata', 10, 2 );
/**
@andreiglingeanu
andreiglingeanu / locks.ozf
Last active May 5, 2017
Define a lock in Mozart
View locks.ozf
declare
C = {NewCell 0}
L = {NewLock}
thread I in
lock L then I in
I = @C
C := I + 1
{Show 'Thread I'}
{Show C}
@andreiglingeanu
andreiglingeanu / race-condition.ozf
Created May 5, 2017
Example of a race condition in Mozart lang
View race-condition.ozf
declare
C={NewCell 0}
thread
C := 1
end
thread
C := 2
end
@andreiglingeanu
andreiglingeanu / classes.ozf
Created May 5, 2017
Classes in Mozart lang. Here we define `NewCounter` class and two objects named `Ctr1` and `Ctr2`.
View classes.ozf
declare
fun {NewCounter}
C Bump Read in
C = {NewCell 0}
fun {Bump}
C := @C + 1
@C
end
View cells.ozf
% note that oz has variables and cells which are different beasts
% variables are more like mathematical structures which conform to
% dataflow laws in Mozart
% https://mozart.github.io/mozart-v1/doc-1.4.0/tutorial/node8.html
declare
C={NewCell 0} % creation of a cell
C:=@C+5 % := is assignment and @ is read
{Show @C}
@andreiglingeanu
andreiglingeanu / generic_pascal.ozf
Created Apr 21, 2017
An example of higher-order programming technique in Mozart lang
View generic_pascal.ozf
declare ShiftLeft ShiftRight FastPascal AddList GenericPascal OpList Add Xor Multiply
fun {GenericPascal Op N}
if N == 1 then [1]
else L in
L={GenericPascal Op N - 1}
{OpList Op {ShiftLeft L} {ShiftRight L}}
end
end