Skip to content

Instantly share code, notes, and snippets.

@manucorporat
manucorporat / gist:4637010
Last active December 11, 2015 17:48
First test, Computer Sciences, Universidad de Valladolid, January 2013.
// PART 3
static void metodo3(NotaAlumnoAsignatura [] a)
{
int current = a[0].numAlumno;
double total = 0;
int nuNotas = 0;
try {
PrintWriter salida = new PrintWriter(new FileWriter("Notas.txt"));
for(int i = 0; i < a.lenght; ++i) {
@manucorporat
manucorporat / gist:5277108
Created March 30, 2013 15:30
Simulation in python of the probability that two randomly chosen numbers are coprime, is close to 6 / PI^2
# Simulation created by Manuel Martinez-Almeida
# http://en.wikipedia.org/wiki/Coprime_integers
import fractions
import math
import random
def calculateProbability(end, steps):
count = 0
@manucorporat
manucorporat / gist:5726177
Last active December 18, 2015 04:29
Smart way to profile algorithms in C. Full project with examples coming soon!!
#include <stdio.h>
#include <stdbool.h>
#include <sys/time.h>
typedef struct _profile_buf {
const char *title;
unsigned long long total;
unsigned long long index;
struct timeval timestamp;
} profile_buf;
@manucorporat
manucorporat / gist:8229938
Created January 3, 2014 00:14
C++'s dynamic_cast implemented for Objective-C
#define DYNAMIC_CAST(__CLASS__, __OBJ__) ((__CLASS__*)([__OBJ__ isKindOfClass:[__CLASS__ class]] ? __OBJ__ : nil))
#include <stdio.h>
void printDiagonals(int rows, int columns, int matrix[][columns])
{
int iterations = rows + columns - 1;
for(int i = 0; i < iterations; ++i) {
int x = (i >= columns) ? columns-1 : i;
int y = i-x;
do {
@manucorporat
manucorporat / gist:10d4dd62d8992ed33479
Created July 3, 2014 13:32
This doesn't work either
package main
import "net/http"
import "time"
func main() {
http.HandleFunc("/ping", func1)
http.HandleFunc("/ping2", func2)
http.ListenAndServe(":8081", nil)
package main
import (
"fmt"
"github.com/gin-gonic/gin" // at 30ea9c06fc9cac893f10d6ad0847a510cf35aeaf
"time"
)
func main() {
r := gin.NewWithConfig(gin.Config{
package main
import (
"fmt"
"math/rand"
"time"
)
var manos [][]int
var baraja []int
**I'm submitting a ...** (check one with "x")
[ ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use the #go-git tag in stackoverflow.
**How would the same operation be performed using git from the command line terminal?**
<!-- Describe how the same operation can be performed sucessfully using the official git implementation -->
**Current behavior:**
<!-- Describe how the bug manifests. -->
import { Component, Element, Event, EventEmitter, Listen, Method, Prop, PropDidChange } from '@stencil/core';
/**
* GUIDE STYLE FOR STENCIL COMPONENTS
* -
*/
@Component({
tag: 'ion-something',
styleUrl: 'something.scss',
styleUrls: {