Skip to content

Instantly share code, notes, and snippets.

View 1xch's full-sized avatar
🏠
Working from home

1xch

🏠
Working from home
  • laughs-in-flowers
View GitHub Profile
@1xch
1xch / file_open.go
Created February 27, 2019 15:43
my goto file open in go
import (
"github.com/Laughs-In-Flowers/xrr"
)
func openFile(path string) (*os.File, error) {
p := filepath.Clean(path)
dir, name := filepath.Split(p)
var fp string
package cosmic
import (
"fmt"
"math"
"math/rand"
"time"
cr "github.com/Laughs-In-Flowers/ifriit/lib/art/color"
"github.com/Laughs-In-Flowers/ifriit/lib/art/image"
package main
import (
"image"
"image/color"
"math"
mr "math/rand"
"time"
m "github.com/go-gl/mathgl/mgl64"
@1xch
1xch / table.cc
Last active August 29, 2015 14:26
table of grids that are maps of locations accessed by grid layer or location
#include <cmath>
#include <stdio.h>
#include <iostream>
#include "table.h"
bool Cubic::operator==(const Cubic& o) const {
return (X == o.X && Y == o.Y && Z == o.Z);
}
Cubic Cubic::operator+(const Cubic& o) const {
@1xch
1xch / benchmark.go
Last active August 29, 2015 14:14
flotilla benchmark
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"runtime"
"testing"
@1xch
1xch / actors_receivers
Last active August 29, 2015 14:02
closer approximation
"""
This gist provides several mixins to be used on any number of sqlachemy models
1. HasLogMixin, provides a list EntityLog items specific and attached to an instance of the class
2. IsActor or IsReceiver mixins that allow the class to be related to an EntityLog item
as an actor or receiver
The ideal goal is EntityLog items, relatable to specific instances, and queryable by actor/receiver
attachable to any number of items with mixins.
@1xch
1xch / modal_search.lua
Last active December 31, 2015 16:09
modal search for awesomewm/lua
require("awful")
default_search_modes = {
i = {prompt="IMDB", search="https://imdb.com/"},
w = {prompt="Wikipedia", search="https://wikipedia.com/"},
g = {prompt="Google", search="https://google.com/"},
}
local function create_wbox()
wbox = awful.wibox({ position = "bottom", ontop = true, screen = mouse.screen })
@1xch
1xch / header_context_processor.py
Created April 9, 2013 02:55
A simple header w/context processor
def topbar_pack(current_user):
if current_user.get_id():
nav_pack = nav_in_pack()
user_pack = user_in_pack()
else:
nav_pack = nav_out_pack()
user_pack = user_out_pack()
tp = get_template_attribute('macros/topbar.html', 'topbar')
return tp(nav_pack, user_pack, current_user)
@1xch
1xch / flask_app_information.py
Last active December 15, 2015 23:19
Return some information about your flask application
def app_info(app):
''' information about your flask application'''
import pprint
pp = pprint.PrettyPrinter(indent=4)
config_list = []
for k, v in app.config.iteritems():
config_list.append("{}: {}".format(k, v))
pp.pprint(config_list)
map_list = []
for i in app.url_map.iter_rules():
@1xch
1xch / gist:5311922
Created April 4, 2013 16:36
deprecated InternalMacro
class InternalMacro(object):
Manipulates or creates a macro given a name, macro text, and type of content to fill(is_tuple, is_dict, is_list, is_file).
Set content_is to 'passthrough' and kwarg 'to_pass' to move "something else" through this (useful where you
need to mix "something else" with internal macros for this a use case of this class, e.g. internally collating varied
aggregations of macros dependent on varied states or permissions
def __init__(self, name = None,
text = None,