Skip to content

Instantly share code, notes, and snippets.

amn

  • asdf and jkl;
Block or report user

Report or block amn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@amn
amn / set-security-info-by-sddl.c
Last active Mar 15, 2019
Demonstrates how using SetFileSecurity does not result in a [file] ACL with ACEs inherited from parent [folder], while using SetNamedSecurityInfo does, as is proper. Disable (comment) the `SetNamedSecurityInfo` call along with its parent `if` statement and enable (uncomment) the following `SetFileSecurity` call (and its parent `if` statement, ob…
View set-security-info-by-sddl.c
/*
Demonstrates how using SetFileSecurity does not result in a [file] ACL with ACEs inherited from parent [folder], while using SetNamedSecurityInfo does, as is proper.
Disable (comment) the `SetNamedSecurityInfo` call along with its parent `if` statement and enable (uncomment) the following `SetFileSecurity` call (and its parent `if` statement, obviously) to switch the behavior and observe different resultant ACL on the file.
The Windows application entry point in this snippet expects two command line arguments -- the file path of the file you want to set security information on, and the actual security (specified in SDDL format) information desired for the file.
*/
#include <windows.h>
#include <shellapi.h>
@amn
amn / IntersectionObserver.js
Created Dec 10, 2018
An implementation of IntersectionObserver class, after http://w3c.github.io/IntersectionObserver, with some deviations
View IntersectionObserver.js
/** An implementation of the IntersectionObserver class, as specified by http://w3c.github.io/IntersectionObserver. There are some open issues with the later specification, but an attempt is made here to follow it to the best of ability, unless it is found too difficult to interpret -- the motivation is, after all, to have a working implementation, and as certain elements of specification weren't clarifying in themselves, these parts of implementation may turn out to be lacking or even incorrect.
This was initially written to plug in in user agents that do not provide their own implementation, like Safari on iOS 9.3.5. Hence, the used syntax flavour is such as to work in said user agent. */
IntersectionObserver = (function() {
/** Find intersection product of two rectangles `a` and `b`, itself a rectangle. Essentially, this function is the logical AND operation for rectangles. A rectangle with zero width and/or height is returned if `a` and `b` are adjacent but do not overlap in that axis. No rectangle is re
View goodhost.c
/*
A Windows desktop application that opens a log file, and loads a child process program redirecting its standard output and error streams to aforementioned log file. Useful if you have a blackbox program that writes to standard output and error streams but does not necessarily allocate a console, or if you don't want to alter the program to add a bunch of debugging facilities -- just launch the program with this application and get the log for free.
*/
#include <assert.h>
#include <crtdbg.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
struct parse_command_line_result {
@amn
amn / auth-w-tokens-ex-1.py
Last active Jun 1, 2017
Authentication with tokens, example
View auth-w-tokens-ex-1.py
import datetime
""" Secrets, must not be shared. """
token_encrypt_decrypt_key = "<YOUR-KEY-TEXT>";
good_token_salt = "<YOUR-SALT-TEXT>";
# Placeholders: encrypt, decrypt, current_date, get_client_ipv4_addr, client_send, Error,
def make_auth_token(username, ipv4_addr, expires):
""" Compose and return an authentication token that can be given to the client (only over private [secure] channel). """
@amn
amn / cygadmin.sh
Last active Aug 4, 2016
Download fresh copy of Cygwin installer if current copy is stale, and invoke it without administration rights (user-local install)
View cygadmin.sh
#!/bin/sh -ue
# Usage: /path/to/cygadmin.sh [preferred/path/to/setup-x86_64.exe]
# If first argument is omitted, this script behaves as if the value was ".", i.e. current working directory.
# If setup file exists, its extended attributes are checked to see if a property called 'etag' is attached. If it is, its value is used in HTTP request to Cygwin website to download the installer. The website will reply with "not modified, use your own copy" if etag values match, and in this case, the existing setup file will be used. This is in effect local caching of Web resources, the same thing your browser does, but through command line. The setup file is invoked with '--no-admin' option, because my Windows install is managed by crazy paranoid system administrators of our organization where even professionals are not trusted with Administrator role.
# When a fresh installer file is downloaded, an extended attribute with the name 'etag' is attached to it, value being as present in HTTP response. All this so that the c
You can’t perform that action at this time.