Skip to content

Instantly share code, notes, and snippets.

View fallenleavesguy's full-sized avatar
🌴
On vacation

fallenleavesbuy fallenleavesguy

🌴
On vacation
View GitHub Profile
@fallenleavesguy
fallenleavesguy / Commit emoji convention.md
Created May 31, 2016 01:42
Commit emoji convention
  • 📝 Add comment or doc
  • 🎁 New feature.
  • 🐛 Bug fix
  • 💣 Breaking compatibility.
  • ✅ Write test.
  • 🔥 Remove something.
  • 🍺 I'm happy like reduced code complexity.
@fallenleavesguy
fallenleavesguy / vuex-modules.js
Created April 19, 2017 02:35
vue-common-snippets
const state = {
}
const getters = {
}
const actions = {
@fallenleavesguy
fallenleavesguy / wc.c
Last active September 10, 2017 16:36
Word Count in c
/**
* simple word count in c
*/
#include <stdio.h>
#define IN 1
#define OUT 0
int main(int argc, const char * argv[]) {
int c, nl, nw, nc, state;
@fallenleavesguy
fallenleavesguy / simple-grep.c
Last active September 10, 2017 16:35
simple grep in c
/**
* simple grep in c
*/
#include <stdio.h>
#define MAXLINE 1000
int getOneLine(char line[], int max);
int strindex(char source[], char searchfor[]);
char pattern[] = "ould";
@fallenleavesguy
fallenleavesguy / variable-arguments.c
Created September 16, 2017 15:36
variable-arguments in c
#include <stdarg.h>
#include <stdio.h>
void minprintf(char *fmt, ...);
void minprintf(char *fmt, ...) {
va_list ap;
char *p, *sval;
int ival;
@fallenleavesguy
fallenleavesguy / cat.c
Last active October 1, 2017 14:04
cat program in c
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *fp;
void filecopy(FILE *, FILE *);
char *prog = argv[0];
if (argc == 1)
@fallenleavesguy
fallenleavesguy / search-jpg.m
Last active October 7, 2017 18:13
recursive search jpg file in home.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
NSLog(@"beginning search...");
@autoreleasepool
{
NSFileManager *manager = [NSFileManager defaultManager];
NSString *home = [@"~" stringByExpandingTildeInPath];
@fallenleavesguy
fallenleavesguy / ellipse-interpolation.js
Last active January 23, 2018 01:04
ellipse interpolation
export function ellipseInterpolation(x, y, radiusX, radiusY, startProgress = 0, clockwise = true) {
const dir = ( clockwise ? 1 : -1);
return function (t) {
t = (t + startProgress);
const radian = t * Math.PI * dir * 2;
return {
x: radiusX * Math.cos(radian) + x,
y: radiusY * Math.sin(radian) + y
};
}
@fallenleavesguy
fallenleavesguy / tcping.py
Created February 18, 2019 04:49 — forked from defnull/tcping.py
TCPing
def ping(server, port):
''' Check if a server accepts connections on a specific TCP port '''
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((server, port))
s.close()
return True
except socket.error:
return False
@fallenleavesguy
fallenleavesguy / format.date.js
Created December 29, 2019 12:25 — forked from ptquang86/format.date.js
JavaScript Date Format
//http://blog.stevenlevithan.com/archives/date-time-format
//http://stevenlevithan.com/assets/misc/date.format.js
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>