Skip to content

Instantly share code, notes, and snippets.

use std::io::{File,IoResult,UserRWX};
use std::os;
use std::io::TempDir;
use std::io::fs;
pub struct FileUtils {
pub path:Option<TempDir>
}
impl FileUtils {
#pragma strict
import System.Collections.Generic;
/** Create a new instance */
public static function factory(dx:int, dy:int, size:float):TacticsMap {
var rtn = new TacticsMap();
rtn.tiles = new int[dx * dy];
rtn.heights = new int[dx * dy];
rtn.dx = dx;
@shadowmint
shadowmint / errors.
Created August 30, 2014 07:37
errors
dougs-Mac-mini:rust-array doug$ cargo test
Compiling array v0.1.6 (file:///Users/doug/dev/rust-array)
src/array.rs:140:64: 140:72 error: explicit lifetime bound required
src/array.rs:140 impl<'a, T: PartialEq + Clone + Default> Index<uint,T> for &'a Array<T> {
^~~~~~~~
src/array.rs:147:71: 147:79 error: explicit lifetime bound required
src/array.rs:147 impl<'a, T: PartialEq + Clone + Default> IndexMut<uint,T> for &'a mut Array<T> {
^~~~~~~~
src/view.rs:13:14: 13:22 error: explicit lifetime bound required
src/view.rs:13 parent:&'a Array<T>,
impl<'a> Iterator<Path> for GlobIter<'a> {
fn next(&mut self) -> Option<Path> {
match self.walker {
Some(ref mut walker) => {
let mut ended = false;
while !ended {
match walker.next() {
Some(v) => {
match v.lstat() {
Ok(stats) => {
@shadowmint
shadowmint / SassMeister-input.scss
Created August 27, 2014 00:36
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.0)
// ----
@function str-split($value) {
$rtn: ();
$tmp: $value;
$busy: true;
@while $busy {
/// Invoke this when the last 'length' nodes are all the same repeat type.
/// If the node before the first one is *also* that type, merge into that
/// node; otherwise perform the default repeat action.
fn reduce_repeat<'a>(&self, stack:&mut Vec<AstNode<'a, T>>, id:T, length:uint) {
let mut merged:Vec<AstNode<'a, T>> = Vec::new();
for i in range(0, length) {
merged.push(stack.pop().unwrap());
}
trace!("Trying to peform a repeat reducation...!")
@shadowmint
shadowmint / magic.scss
Last active August 29, 2015 14:05
Sass magic
@function str-split($value) {
$rtn: ();
$tmp: $value;
$busy: true;
@while $busy {
$index: str-index($tmp, ' ');
@if $index {
$bit: str-slice($tmp, 0, $index - 1);
$rtn: append($rtn, $bit);
$tmp: str-slice($tmp, $index + 1);
@shadowmint
shadowmint / errors
Last active August 29, 2015 14:05
boo
Fresh array v0.1.4 (https://github.com/shadowmint/rust-array?ref=0.1.5#f574f1a3)
Compiling txt v0.1.0 (file:///Users/doug/dev/rust-txt)
src/parser/parser.rs:63:18: 63:35 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
src/parser/parser.rs:63 for token in ast.tokens.iter() {
^~~~~~~~~~~~~~~~~
src/parser/parser.rs:62:3: 83:4 note: consider using an explicit lifetime parameter as shown: fn phase_pattern_match(&'a self, ast: &'a mut Ast<'a, T>)
src/parser/parser.rs:62 fn phase_pattern_match(&'a self, ast:&mut Ast<'a, T>) {
src/parser/parser.rs:63 for token in ast.tokens.iter() {
src/parser/parser.rs:64 let mut matched = false;
src/parser/parser.rs:65 self.patterns.iter().all(|pattern| -> bool {
src/string.rs:371:3: 379:4 note: consider using an explicit lifetime parameter as shown: fn clone(&self) -> String<'a>
src/string.rs:371 fn clone(&self) -> String<'b> {
src/string.rs:372 return String {
src/string.rs:373 len: self.len,
src/string.rs:374 bytes: match self.bytes {
src/string.rs:375 IsStatic(ref x) => IsStatic(x.as_array().clone()),
src/string.rs:376 IsView(ref x) => IsStatic(x.as_array().clone())
...
src/string.rs:371:3: 379:4 error: method not compatible with trait: expected `fn(&string::String<'a>) -> string::String<'a>` but found `fn(&string::String<'a>) -> string::String<'b>` (lifetime mismatch)
src/string.rs:371 fn clone(&self) -> String<'b> {
def url(self, image, width=None, height=None):
"""Generate a scaled image url from the given values """
if width is None:
width = image.width
if height is None:
height = image.height
scales = image.restrictedTraverse('@@images')
scaled_image = scales.scale(
'image',
width=width,