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 <string.h> | |
void strrev(char *str) | |
{ | |
char tmp, *end; | |
if (str) { | |
end = str + strlen(str) - 1; | |
while (str < end) { |
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 <algorithm> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
// is_vowel returns true if the given | |
// character is a vowel; false otherwise. | |
bool is_vowel(char c) | |
{ |
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
CXXFLAGS = -g -Wall -Werror -std=c++11 | |
LDLIBS = | |
PRGM = project | |
SRCS := $(wildcard *.cpp) | |
OBJS := $(SRCS:.cpp=.o) | |
DEPS := $(OBJS:.o=.d) | |
.PHONY: all clean |
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
std::string slurp(const std::string& filename) | |
{ | |
// Open the file into an input file stream | |
std::ifstream ifile(filename, std::ios::in | std::ios::binary | std::ios::ate); | |
// Check that the file exists | |
if (ifile) { | |
std::string str; | |
// Move to the end of the file | |
ifile.seekg(0, std::ios::end); |
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
#!/bin/bash | |
function _p4() | |
{ | |
local cmds='add annotate attribute branch branches change changes changelist changelists client clients copy | |
counter counters cstat delete depot depots describe diff diff2 dirs edit filelog files fix fixes flush fstat grep | |
group groups have help info integrate integrated interchanges istat job jobs key keys label labels labelsync list | |
lock logger login logout merge move open opened passwd populate print protect protects reconcile rename reopen | |
resolve resolved revert review reviews set shelve status sizes stream streams submit sync tag tickets unlock | |
unshelve update user users where workspace workspaces' |
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
import sys | |
import re | |
class Bear: | |
def __init__(self, attrs): | |
self.parents = [] | |
self.name = attrs[0] | |
if len(attrs) > 1: | |
self.sex = attrs[1] | |
self.parents = attrs[2:4] |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import json | |
def tally(voters): | |
results = {} | |
for votes in voters.itervalues(): | |
if votes: |
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 <algorithm> | |
#include <iostream> | |
#include <list> | |
#include <vector> | |
template<typename Iter> | |
void print(const Iter& beg, const Iter& end, bool new_line = true) | |
{ | |
std::for_each(beg, end, [](auto& i) { std::cout << i << " "; }); | |
if (new_line) { |
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 <algorithm> | |
#include <iostream> | |
#include <list> | |
template<typename Iter> | |
void print(const Iter& beg, const Iter& end) | |
{ | |
std::for_each(beg, end, [](auto& i) { std::cout << i << " "; }); | |
std::cout << std::endl; | |
} |
OlderNewer