src post: https://programming.dev/post/5896373

type Wtf = Option<Option<Option<Option<Option<Option<Option<Option<()>>>>>>>>;
let two = Some(Some(Some(Some(Some(Some(None))))));
let three = Some(Some(Some(Some(Some(None)))));
let six = Some(Some(None));
unsafe {
    assert_eq!(
        std::mem::transmute::<Wtf, u8>(two) * std::mem::transmute::<Wtf, u8>(three),
        std::mem::transmute::<Wtf, u8>(six)
    );
}
  • bmzero3@kbin.asdfzdfj.xyzOP
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    testing solarized themes

    src sample from ref img from

    c

    ref dark ref light

    #define UNICODE
    #include 
    
    int main(int argc, char **argv) {
      int speed = 0, speed1 = 0, speed2 = 0; // 1-20
      printf("Set Mouse Speed by Maverick\n");
    
      SystemParametersInfo(SPI_GETMOUSESPEED, 0, &amp;speed, 0);
      printf("Current speed: %2d\n", speed);
    
      if (argc == 1) return 0;
      if (argc >= 2) sscanf(argv[1], "%d", &amp;speed1);
      if (argc >= 3) sscanf(argv[2], "%d", &amp;speed2);
    
      if (argc == 2) // set speed to first value
        speed = speed1;
      else if (speed == speed1 || speed == speed2) // alternate
        speed = speed1 + speed2 - speed;
      else
        speed = speed1;  // start with first value
    
      SystemParametersInfo(SPI_SETMOUSESPEED, 0,  speed, 0);
      SystemParametersInfo(SPI_GETMOUSESPEED, 0, &amp;speed, 0);
      printf("New speed:     %2d\n", speed);
      return 0;
    }
    

    js

    ref dark ref light

    /**
    sample javascript from xui
    */
    
    var undefined,
        xui,
        window     = this,
        string     = new String('string'),
        document   = window.document,
        simpleExpr = /^#?([\w-]+)$/,
        idExpr     = /^#/,
        tagExpr    = /&lt;([\w:]+)/,
        slice      = function (e) { return [].slice.call(e, 0); };
        try { var a = slice(document.documentElement.childNodes)[0].nodeType; }
        catch(e){ slice = function (e) { var ret=[]; for (var i=0; e[i]; i++)
            ret.push(e[i]); return ret; }; }
    
    window.x$ = window.xui = xui = function(q, context) {
        return new xui.fn.find(q, context);
    };
    
  • bmzero3@kbin.asdfzdfj.xyzOP
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    testing solarized theme 2

    python

    ref dark ref light

    # test python (sample from offlineimap)
    
    class ExitNotifyThread(Thread):
        """This class is designed to alert a "monitor" to the fact that a thread has
        exited and to provide for the ability for it to find out why."""
        def run(self):
            global exitthreads, profiledir
            self.threadid = thread.get_ident()
            try:
                if not profiledir:          # normal case
                    Thread.run(self)
                else:
                    try:
                        import cProfile as profile
                    except ImportError:
                        import profile
                    prof = profile.Profile()
                    try:
                        prof = prof.runctx("Thread.run(self)", globals(), locals())
                    except SystemExit:
                        pass
                    prof.dump_stats( \
                                profiledir + "/" + str(self.threadid) + "_" + \
                                self.getName() + ".prof")
            except:
                self.setExitCause('EXCEPTION')
                if sys:
                    self.setExitException(sys.exc_info()[1])
                    tb = traceback.format_exc()
                    self.setExitStackTrace(tb)
            else:
                self.setExitCause('NORMAL')
            if not hasattr(self, 'exitmessage'):
                self.setExitMessage(None)
    
            if exitthreads:
                exitthreads.put(self, True)
    

    shell

    ref dark ref light

    #!/bin/bash
    
    cd $ROOT_DIR
    DOT_FILES="lastpass weechat ssh Xauthority"
    for dotfile in $DOT_FILES; do conform_link "$DATA_DIR/$dotfile" ".$dotfile"; done
    
    # }}}
    # crontab update from file {{{
    # TODO: refactor with suffix variables (or common cron values)
    
    case "$PLATFORM" in
    	linux)
            #conform_link "$CONF_DIR/shell/zshenv" ".zshenv"
            crontab -l > $ROOT_DIR/tmp/crontab-conflict-arch
            cd $ROOT_DIR/$CONF_DIR/cron
            if [[ "$(diff ~/tmp/crontab-conflict-arch crontab-current-arch)" == "" 
                ]];
                then # no difference with current backup
                    logger "$LOG_PREFIX: crontab live settings match stored "\
                        "settings; no restore required"
                    rm ~/tmp/crontab-conflict-arch
                else # current crontab settings in file do not match live settings
                    crontab $ROOT_DIR/$CONF_DIR/cron/crontab-current-arch
                    logger "$LOG_PREFIX: crontab stored settings conflict with "\
                        "live settings; stored settings restored. "\
                        "Previous settings recorded in ~/tmp/crontab-conflict-arch."
            fi 
        ;;
    
  • bmzero3@kbin.asdfzdfj.xyzOP
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    another test of line fuckyness, now posted from a mac

    ---
    
    # useless comment
    - name: install newline
      package:
        name: [ git, curl, neovim, bash, zsh, ripgrep, bat, bind-tools, mtr-nox11, btop, htop ]
        state: present