Skip to content

Instantly share code, notes, and snippets.

View nightfly19's full-sized avatar

Sage Imel nightfly19

  • Portland State University
  • Portland, Oregon
View GitHub Profile
@nightfly19
nightfly19 / wrapper.rs
Created February 21, 2022 09:21
Window wrapper for SDL2 and WGPU
use sdl2::video::Window;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use raw_window_handle::AppKitHandle;
pub struct WindowWrapper<'a>(pub &'a Window);
unsafe impl<'a> HasRawWindowHandle for WindowWrapper<'a> {
#[cfg(not(target_os = "macos"))]
/// all non-mac platforms work correctly, so return the handle directly
fn raw_window_handle(&self) -> RawWindowHandle {
@nightfly19
nightfly19 / regex.js
Created August 7, 2016 18:31
Weird Javascript Regex behavior
#!/usr/bin/nodejs
//var regexRegex = /^\/([^\/]|(\\\/))*\/[gimy]*/;
var regexRegex = /^\/([^\/]|(\\\/))*\/[gimy]*/;
var regexRegexAsString = '^/([^\/]|(\\/))*/[gimy]*';
var notQuiteRegexRegex = /^"([^\/]|(\\"))*"[gimy]*/;
var notQuiteRegexSearchString = '"hello world\\" hows it going?"igmyi';
var regexSearchString = notQuiteRegexSearchString.replace(/"/g,'/');
var Heap = (function(){
function otheri(index, level_offset){
var level = Math.floor(Math.log2(index+1));
var level_start = Math.pow(2, level) - 1;
var offset = index - level_start;
var other_level_start = Math.pow(2, level + level_offset) -1;
var other_offset = Math.floor(offset * Math.pow(2, level_offset));
return other_level_start + other_offset;
};
@nightfly19
nightfly19 / gist:ef5d907deeb5c1c8e1f2
Created September 13, 2014 18:46
Notes from Bart's webcomics session at CAT BarCamp
https://xkcd.com/
http://www.schlockmercenary.com
http://axecop.com/
http://www.gunnerkrigg.com/
http://avasdemon.com/
http://www.smbc-comics.com/
http://www.qwantz.com/index.php
http://www.lackadaisycats.com/
http://thepunchlineismachismo.com/
http://www.darthsanddroids.net/
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/ansible/runner/connection_plugins/paramiko_ssh.py", line 330, in close
self.ssh.load_system_host_keys()
File "/usr/lib/python2.6/site-packages/paramiko/client.py", line 149, in load_system_host_keys
self._system_host_keys.load(filename)
File "/usr/lib/python2.6/site-packages/paramiko/hostkeys.py", line 155, in load
e = HostKeyEntry.from_line(line)
File "/usr/lib/python2.6/site-packages/paramiko/hostkeys.py", line 67, in from_line
key = RSAKey(data=base64.decodestring(key))
File "/usr/lib/python2.6/site-packages/paramiko/rsakey.py", line 61, in __init__
#include <stdio.h>
#include <stdint.h>
int main(int argc, char** argv){
char cow2[5][4];
cow2[3][4] = 10;
cow2[0][0] = 1;
cow2[0][1] = 2;
printf("moo:%i\n", *((char*) cow2+(4*3+4)));
return 0;
}
#include <stdio.h>
#include <stdint.h>
int main(int argc, char** argv){
char cow2[5][4];
cow2[3][4] = 10;
cow2[0][0] = 1;
cow2[0][1] = 2;
printf("moo:%i\n", *((char*) cow2+(4*3+4)));
return 0;
}
@nightfly19
nightfly19 / subnet_hosts.sql
Last active August 29, 2015 14:01
subnet_hosts
create or replace function subnet_hosts(subnet cidr) returns setof inet as $$
declare
host inet := (inet (host(network(subnet))));
broadcast inet := (inet (host(broadcast(subnet))));
begin
if family(subnet) = 4 then
-- /32's are a special case
if masklen(subnet) = 32 then
return next subnet;
return;
@nightfly19
nightfly19 / gist:9633761
Last active August 29, 2015 13:57
'Fail's behavior within a selector
# Currently the pattern used when implementing a params class is something like this.
# It works but is very verbose for what it does.
class puppet::params{
# In this case we are only specializing based on one parameter
case $::osfamily {
'Debian': {
$conf_file_path = '/etc/puppet/puppet.conf'
}
default: {
root@scootaloo:/var/log# cat auth.log | cut -b -6 | sort | uniq -c
4631 Mar 10
2097 Mar 11
2780 Mar 12
1584 Mar 13
2520 Mar 14
3782 Mar 9