Skip to content

Instantly share code, notes, and snippets.

View 1xch's full-sized avatar
⛈️
head in the clouds

1xch

⛈️
head in the clouds
  • laughs-in-flowers
View GitHub Profile
@1xch
1xch / ???????????????
Created July 25, 2011 13:02
rvm issue
Ubuntu 11.04
zsh
--shell loads
/home/qx/.rvm/scripts/initialize:43: bad pattern: (/home/qx/.bash_profile
/home/qx/.rvm/scripts/initialize:43: bad pattern: (/home/qx/.bash_profile
% ➜ ~ rvm -v | 8:53:11 |
/home/qx/.rvm/scripts/initialize:43: bad pattern: (/home/qx/.bash_profile
rvm 1.6.25 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
```
class Ticket
include DataMapper::Resource
if Rails::DataMapper.configuration.repositories["development" || "test" || "production"]["ticketengine"]
def self.default_repository_name
:ticketengine
end
end
@1xch
1xch / gist:5166807
Last active December 14, 2015 23:39
Manage jinja2 macros with code
from flask import get_template_attribute
from jinja2 import Template
class MacroFor(object):
""" Use this as a mixin
e.g.
class ListItemBasic(MacroFor):
def __init__(self, listitem):
self.title = listitem.title
@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,
@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 / 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 / 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 / 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 / benchmark.go
Last active August 29, 2015 14:14
flotilla benchmark
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"runtime"
"testing"
@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 {