Skip to content

Instantly share code, notes, and snippets.

fn get_longest(v: &[String]) -> &str {
assert!(v.len() > 0);
let mut result = &v[0];
for s in v {
if s.len() > result.len() {
result = &s
}
}
result.as_str()
}
@function hsv($h, $s, $v) {
@return mix(mix(
if($h < 60, rgb(255, $h/60*255, 0),
if($h < 120, rgb((120-$h)/60*255, 255, 0),
if($h < 180, rgb(0, 255, ($h-120)/60*255),
if($h < 240, rgb(0, (240-$h)/60*255, 255),
if($h < 300, rgb(($h-240)/60*255, 0, 255),
rgb(255, 0, (360-$h)/60*255)))))),
#fff, $s), #000, $v);
}
fn is_prime(x: i32) -> bool {
(2..).take_while(|i| i * i <= x).all(|i| x % i != 0)
}
trait Peg {
fn p(&self, s: &mut &str) -> bool;
}
struct Wrap<T>(T);
impl<T: Peg> Peg for Wrap<T> {
fn p(&self, s: &mut &str) -> bool {
self.0.p(s)
}
@eyelash
eyelash / CMakeLists.txt
Created September 29, 2016 14:02
Cocoa
project(test)
find_library(COCOA Cocoa)
add_executable(test MACOSX_BUNDLE main.m)
target_link_libraries(test ${COCOA})
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
<edit name="hinting" mode="assign">
<bool>true</bool>
#include <stdint.h>
static uint32_t mul (uint32_t x1, uint32_t x2, uint32_t m) {
return ((uint64_t)x1 * (uint64_t)x2) % m;
}
static uint32_t pow (uint32_t b, uint32_t e, uint32_t m) {
if (e == 0) return 1;
uint32_t f = 1;
// invariant: f*b^e
#include <iterator>
template <class I, class F> class Map {
I _begin;
I _end;
F f;
public:
Map(const I& _begin, const I& _end, const F& f): _begin(_begin), _end(_end), f(f) {}
class Iterator {
I i;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eyelash
eyelash / PKGBUILD
Created May 1, 2016 08:50
Adapta PKGBUILD
pkgname=adapta-gtk-theme
pkgver=3.20.3.106
pkgrel=1
pkgdesc="An adaptive Gtk+ theme based on Material Design Guidelines"
arch=('any')
url="https://github.com/tista500/Adapta"
license=('GPL2')
depends=('gtk3')
source=("https://github.com/tista500/Adapta/archive/$pkgver.tar.gz")
sha256sums=('SKIP')