Skip to content

Instantly share code, notes, and snippets.

View rich-97's full-sized avatar
🏠
Working from home

Ricardo Moreno rich-97

🏠
Working from home
View GitHub Profile
@rich-97
rich-97 / asterisks.c
Created October 30, 2016 01:46
Program that generate a pyramid with asterisks
#include "stdio.h"
int row;
int column;
int count_char;
int length_rows;
int index_columns;
int length_columns;
void print (int count) {
@rich-97
rich-97 / longer-word.c
Last active November 10, 2016 19:06
the longest word
#include "stdio.h"
#include "string.h"
int count = 0;
int max_len = 0;
int count_comp = 0;
int count_word = 0;
int count_index = 0;
int len = strlen(str);
int arr_nword[count_word];
@rich-97
rich-97 / longer-word.py
Last active November 14, 2016 14:37
the longest word in python
string = 'example example2 proof guide'
listStr = string.split()
listLength = [len(i) for i in listStr]
for i in listStr:
if (max(listLength) == len(i)):
print i
@rich-97
rich-97 / longer-word.js
Created November 10, 2016 19:10
the longest word in javascript
'use strict';
const str = 'example example2 proof guide';
const arr = str.split(' ');
const arrLength = [];
for (let i of arr) arrLength.push(i.length);
const max = Math.max.apply(null, arrLength);
for (let i = 0; i < arr.length; i++) {
@rich-97
rich-97 / reverse-str.c
Last active November 10, 2016 19:14
reverse a string
#include "stdio.h"
#include "string.h"
int main () {
char str[] = "hello";
int len = strlen(str);
for (int i = len; i >= 0; i--)
printf("%c", str[i]);
@rich-97
rich-97 / fibo.sh
Last active December 16, 2016 03:12
Suseción Fibonacci con la Shell Bash.
# Fibo between 0 and 30.
len=30
arr=()
for (( i = 0; i < len; i++ )); do
if (( i > 0 )); then
let arr[i]="arr[i - 1] + arr[i - 2]"
else
let arr[i]=i
fi
@rich-97
rich-97 / lsbin
Created December 24, 2016 20:35
List all binaries of directories in $PATH.
#!/bin/bash
list=${PATH//:/' '}
list=${list//\}/' '}
list=${list//\{/' '}
color () {
if [ -z $1 ]; then
tput setaf 1
else
@rich-97
rich-97 / filter.js
Last active June 10, 2021 14:21
Example of pattern design oriented object in JavaScript.
$(document).ready(function () {
var $btn = $('.btn');
var $image = $('#img');
function Filter (config) {
this.target = config.target;
this.image = config.image;
this.filters = config.filters;
this.support = config.support === undefined ? true : config.support;
@rich-97
rich-97 / postgres cheatsheet.md
Created January 17, 2017 00:56 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@rich-97
rich-97 / server.js
Created February 7, 2017 19:05
A small server with nodejs in four lines.
require('http').createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World!\n');
}).listen(8080);