This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
def __init__(self, a_value): | |
self._a = None # Create private instance variable: _a | |
self.set_a(a_value) # Re-use the setter method so do validation and set the actual value | |
def get_a(self): | |
return self._a | |
def set_a(self, new_value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
def __init__(self, a_value): | |
self.a = a_value # Create public instance variable and assign it | |
f = Foo(123) | |
print(f.a) | |
f.a = 1 | |
print(f.a) | |
f.a = -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(object): | |
def __init__(self, a_value): | |
self._a = None # Create private instance variable: _a | |
self.a = a_value # Re-use the setter method (in the form of a property) to do validation and set the actual value | |
@property | |
def a(self): # used to be called "get_a" | |
return self._a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void error(const char *msg, const char *file, int line) | |
{ | |
fprintf(stderr, "%s:%d: %s\n", file, line, msg); | |
exit(1); | |
} | |
enum keyword_ { | |
kw_up, | |
kw_down, | |
kw_left, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Exp = Lit Integer | |
| Add Exp Exp | |
| Sub Exp Exp | |
| Mul Exp Exp | |
| Neg Exp | |
| Abs Exp | |
| Sgn Exp | |
| Var Var | |
deriving Show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad (mapM_) | |
import Control.Monad.Trans.Resource (runResourceT) | |
import Data.Conduit | |
import Data.Conduit.Attoparsec (conduitParser) | |
import Data.Conduit.Binary (sourceFile) | |
import qualified Data.Conduit.List as CL | |
import System.Environment (getArgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Lexis.Regex where | |
import Data.Char (ord) | |
import Data.Foldable (asum) | |
import Data.SciRatio.Read (readHexP, readIntegerP, readOctP, readSciRationalP) | |
import Data.Traversable (sequenceA) | |
import Data.Tuple (swap) | |
import Text.ParserCombinators.ReadP (ReadP, readP_to_S) | |
import Text.Regex.Applicative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run with python2 | |
# | |
# Dependencies: | |
# pip install requests beautifulsoup4 | |
import requests | |
import bs4 | |
def main(): | |
print "<!doctype html>".encode("utf-8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#define ERROR(msg) error(msg, __FILE__, __LINE__) | |
#define FAIL() error(__FUNCTION__, __FILE__, __LINE__) | |
#define ASSERT(expr) do { if (!(expr)) { error(#expr, __FILE__, __LINE__); } } while (0) | |
void error(const char *msg, const char *file, int line) |
OlderNewer