Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
void
insertion(int v[], int size)
{
int aux;
for(int i = 0; i < size-1; i++) {
for(int j = i+1; j >= 0 && v[j] < v[j-1]; j--) {
aux = v[j-1];
v[j-1] = v[j];
#include <iostream>
void
bubble(int v[], int size)
{
for(int i = size-1; i >= 1; i--) {
int aux;
for(int j = i; j >= 0; j--) {
if(v[i] < v[j]) {
aux = v[i];
func (a *App) MarshalJSON() ([]byte, error) {
var result map[string]interface{}
result["name"] = a.Name
result["state"] = a.State()
result["platform"] = a.Platform
...
return json.Marshal(result)
}
@fsouza
fsouza / migration.js
Created October 4, 2012 19:37 — forked from flavianmissi/migration.js
mongodb "migration" script
// changes the data in db.collection[from] to
// db.collection[to] and deletes db.collection[from]
// how can I force the execution of the variables from and to?
function changeFieldKey(collection) {
var docs = db[collection].find({"from-key": {$exists: true}});
for (var i = 0; i < docs.length(); i++) {
print(docs[i])
docs[i]["to-key"] = docs[i]["from-key"];
delete docs[i]["from-key"];
print(docs[i])
package main
import (
"os"
"syscall"
"time"
)
func main() {
f, err := os.OpenFile("/Users/f/txaws.diff", syscall.O_RDONLY|syscall.O_EXLOCK, 0644)
=== modified file 'terminal.go'
--- terminal.go 2012-02-21 18:47:37 +0000
+++ terminal.go 2012-08-31 16:29:38 +0000
@@ -5,9 +5,7 @@
package rietveld
import (
- "io"
- "syscall"
- "unsafe"
#--- PYTHON IMPORTS
import math
from datetime import datetime, date
#--- DJANGO IMPORTS
from django.db import models
from django.db.models import Avg
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.template.defaultfilters import slugify
diff -ru a/boto/connection.py b/boto/connection.py
--- a/boto/connection.py 2012-11-29 14:04:38.000000000 -0200
+++ b/boto/connection.py 2012-11-29 11:51:16.000000000 -0200
@@ -658,7 +658,7 @@
return self.new_http_connection(host, is_secure)
def new_http_connection(self, host, is_secure):
- if self.use_proxy:
+ if self.use_proxy and not is_secure:
host = '%s:%d' % (self.proxy, int(self.proxy_port))
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
void
checkError(cudaError_t err, int line)
{
if(err != cudaSuccess) {
printf("%s in %s at line %d\n", cudaGetErrorString(err), __FILE__, line);
exit(EXIT_FAILURE);
@fsouza
fsouza / reverse.c
Last active December 10, 2015 09:38
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct substring
{
char *inner;
int lower, upper;
};