Skip to content

Instantly share code, notes, and snippets.

View fredyfx's full-sized avatar
💭
With all the power 2.0!

Fredy R. Guibert フレディ fredyfx

💭
With all the power 2.0!
View GitHub Profile
// ==UserScript==
// @name SE Chat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Moving Feed new items to the bottom right corner
// @author You
// @match https://chat.stackexchange.com/rooms/30872/stack-overflow-en-espanol
// @grant none
// ==/UserScript==
@fredyfx
fredyfx / solucion1.cs
Created June 19, 2018 22:11
Welcome. In this kata you are required to, given a string, replace every letter with its position in the alphabet. If anything in the text isn't a letter, ignore it and don't return it. a being 1, b being 2, etc. As an example: string to input: ""The sunset sets at twelve o' clock.". Should return "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5…
using System;
using System.Linq;
using System.Text;
public static class Kata
{
public static string AlphabetPosition(string text)
{
//First define the groups:
@fredyfx
fredyfx / UniqueInOrder.cs
Created May 3, 2018 20:49
Jugando con los Generics
using System.Collections.Generic;
public static class Kata
{
public static IEnumerable<T> UniqueInOrder<T>(IEnumerable<T> iterable)
{
List<T> result = new List<T>();
T pre_item = default(T);
foreach (T item in iterable) {
if(!item.Equals(pre_item)){
@fredyfx
fredyfx / program.cs
Last active May 2, 2018 21:31
//Accumul.Accum("abcd"); // "A-Bb-Ccc-Dddd". 2 soluciones: una utilizando un string builder y la otra usando Linq
//Accumul.Accum("abcd"); // "A-Bb-Ccc-Dddd"
//Accumul.Accum("RqaEzty"); // "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
//Accumul.Accum("cwAt"); // "C-Ww-Aaa-Tttt"
public static String Accum(string s)
{
var longitud = s.Length;
Console.WriteLine(longitud);
var arreglo = s.ToCharArray();
@fredyfx
fredyfx / parsingPageNumbersString.cs
Last active April 11, 2018 00:04
C# parsing page-number strings. Esto retorna: Hello World 1 2 3 4 3 5 6 7 8 9 10 12
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
var result = GetNumbers("1-4,3,5-10,12");
@fredyfx
fredyfx / c0w.c
Created January 27, 2018 00:48 — forked from KrE80r/c0w.c
PTRACE_POKEDATA variant of CVE-2016-5195
/*
* A PTRACE_POKEDATA variant of CVE-2016-5195
* should work on RHEL 5 & 6
*
* (un)comment correct payload (x86 or x64)!
* $ gcc -pthread c0w.c -o c0w
* $ ./c0w
* DirtyCow root privilege escalation
* Backing up /usr/bin/passwd.. to /tmp/bak
* mmap fa65a000
@fredyfx
fredyfx / delegados.cs
Created December 2, 2017 20:49
aprendiendo delegados
public void btnEnviar_Click(object sender, EventArgs e){
// Aqui manejamos lo que va a pasar cuando el botón fue clickeado.
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Array Sort</h2>
<p>Click the buttons to sort car objects on type.</p>
<button onclick="myFunction()">Sort</button>
@fredyfx
fredyfx / redBorder.js
Created November 10, 2017 01:26
usando jquery hacemos una animación sencilla resaltando en rojo el borde de la caja de texto donde debemos ingresar información
var contieneValor = ($("#IdDelCampo").val().length > 0);
// si el valor es nulo, dará cero, por lo que será falso
//aquí lo mandamos a verdadero o hacemos un contieneValor == false que viene a ser lo mismo.
if(!contieneValor){
resaltarCampo();
}
function resaltarCampo() {
$("#IdDelCampo").css("border-color", "red");
setTimeout(function () {
@fredyfx
fredyfx / UserDatabase.sql
Created October 11, 2017 08:56
Creando un usuario que utiliza las credenciales para un login.
CREATE USER [NombreDeUsuario]
FOR LOGIN [IIS APPPOOL\DefaultAppPool]
GO
EXEC sp_addrolemember 'db_owner', 'NombreDeUsuario'
GO