-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
371 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hello <- function( name ) { | ||
sprintf( "Hello, %s", name ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <stdio.h> | ||
|
||
int main() | ||
{ | ||
struct foo | ||
{ | ||
int x; | ||
float y; | ||
}; | ||
|
||
struct foo var; | ||
struct foo* pvar; | ||
pvar = &var; | ||
|
||
var.x = 5; | ||
(&var)->y = 14.3; | ||
printf("%i - %.02f\n", var.x, (&var)->y); | ||
pvar->x = 6; | ||
pvar->y = 22.4; | ||
printf("%i - %.02f\n", pvar->x, pvar->y); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <iostream> | ||
#include <vector> | ||
using namespace std; | ||
|
||
// Consider an actual class. | ||
class Obj { | ||
static int i, j; | ||
|
||
public: | ||
void f() const { cout << i++ << endl; } | ||
void g() const { cout << j++ << endl; } | ||
}; | ||
|
||
// Static member definitions: | ||
int Obj::i = 10; | ||
int Obj::j = 12; | ||
|
||
// Implement a container for the above class | ||
class ObjContainer { | ||
vector<Obj*> a; | ||
public: | ||
void add(Obj* obj) { | ||
a.push_back(obj); // call vector's standard method. | ||
} | ||
friend class SmartPointer; | ||
}; | ||
|
||
// implement smart pointer to access member of Obj class. | ||
class SmartPointer { | ||
ObjContainer oc; | ||
int index; | ||
public: | ||
SmartPointer(ObjContainer& objc) { | ||
oc = objc; | ||
index = 0; | ||
} | ||
|
||
// Return value indicates end of list: | ||
bool operator++() // Prefix version { | ||
if(index >= oc.a.size()) return false; | ||
if(oc.a[++index] == 0) return false; | ||
return true; | ||
} | ||
|
||
bool operator++(int) // Postfix version { | ||
return operator++(); | ||
} | ||
|
||
// overload operator-> | ||
Obj* operator->() const { | ||
if(!oc.a[index]) { | ||
cout << "Zero value"; | ||
return (Obj*)0; | ||
} | ||
return oc.a[index]; | ||
} | ||
}; | ||
|
||
int main() { | ||
const int sz = 10; | ||
Obj o[sz]; | ||
ObjContainer oc; | ||
|
||
for(int i = 0; i < sz; i++) { | ||
oc.add(&o[i]); | ||
} | ||
|
||
SmartPointer sp(oc); // Create an iterator | ||
do { | ||
sp->f(); // smart pointer call | ||
sp->g(); | ||
} while(sp++); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<style type="text/css"> | ||
h1 { | ||
color: DeepSkyBlue; | ||
} | ||
</style> | ||
|
||
<h1>Hello, world! nombre-valido </h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Hello World</title> | ||
</head> | ||
<body> | ||
<h1>Hello World</h1> | ||
<p> | ||
Jamie was here. | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/****************************************************************************** | ||
* Compilation: javac HelloWorld.java | ||
* Execution: java HelloWorld | ||
******************************************************************************/ | ||
|
||
public class HelloWorld { | ||
|
||
public static void main(String[] args) { | ||
// Prints "Hello, World" to the terminal window. | ||
System.out.println("Hello, World"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
*Italic* | ||
**Bold** | ||
# Heading 1 | ||
========= | ||
## Heading 2 | ||
--------- | ||
[Link](http://a.com) | ||
[Link][1] | ||
[1]: http://b.org | ||
![Image](http://url/a.png) | ||
![Image][1] | ||
[1]: http://url/b.jpg | ||
> Blockquote | ||
A paragraph. | ||
A paragraph after 1 blank line. | ||
|
||
* List | ||
* List | ||
* List | ||
|
||
- List | ||
- List | ||
- List | ||
|
||
1. One | ||
2. Two | ||
3. Three | ||
|
||
1) One | ||
2) Two | ||
3) Three | ||
|
||
--- Horizontal Rule | ||
|
||
*** Horizontal Rule | ||
`Inline code` with backticks | ||
``` | ||
# code block | ||
print '3 backticks or' | ||
print 'indent 4 spaces' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
********************* VerySimpleWebBrowser ************************ | ||
This is a Very Simple Web Browser implemented over Qt and QtWebKit. | ||
author: Juan Manuel Garcia <[email protected]> ~/home | ||
******************************************************************* | ||
""" | ||
|
||
import numpy as np | ||
|
||
print (__file__) | ||
|
||
def iterate_1(Z): | ||
# Count neighbours | ||
N = np.zeros(Z.shape, int) | ||
N[1:-1,1:-1] += (Z[0:-2,0:-2] + Z[0:-2,1:-1] + Z[0:-2,2:] + | ||
Z[1:-1,0:-2] + Z[1:-1,2:] + | ||
Z[2: ,0:-2] + Z[2: ,1:-1] + Z[2: ,2:]) | ||
N_ = N.ravel() | ||
Z_ = Z.ravel() | ||
|
||
# Apply rules | ||
R1 = np.argwhere( (Z_==1) & (N_ < 2) ) | ||
R2 = np.argwhere( (Z_==1) & (N_ > 3) ) | ||
R3 = np.argwhere( (Z_==1) & ((N_==2) | (N_==3)) ) | ||
R4 = np.argwhere( (Z_==0) & (N_==3) ) | ||
|
||
# Set new values | ||
Z_[R1] = 0 | ||
Z_[R2] = 0 | ||
Z_[R3] = Z_[R3] | ||
Z_[R4] = 1 | ||
|
||
# Make sure borders stay null | ||
Z[0,:] = Z[-1,:] = Z[:,0] = Z[:,-1] = 0 | ||
|
||
|
||
def iterate_2(Z): | ||
# Count neighbours | ||
N = (Z[0:-2,0:-2] + Z[0:-2,1:-1] + Z[0:-2,2:] + | ||
Z[1:-1,0:-2] + Z[1:-1,2:] + | ||
Z[2: ,0:-2] + Z[2: ,1:-1] + Z[2: ,2:]) | ||
|
||
# Apply rules | ||
birth = (N==3) & (Z[1:-1,1:-1]==0) | ||
survive = ((N==2) | (N==3)) & (Z[1:-1,1:-1]==1) | ||
Z[...] = 0 | ||
Z[1:-1,1:-1][birth | survive] = 1 | ||
return Z | ||
|
||
Z = np.array([[0,0,0,0,0,0], | ||
[0,0,0,1,0,0], | ||
[0,1,0,1,0,0], | ||
[0,0,1,1,0,0], | ||
[0,0,0,0,0,0], | ||
[0,0,0,0,0,0]]) | ||
|
||
#print(Z) | ||
for i in range(4): | ||
iterate_2(Z) | ||
#print (Z) |
Oops, something went wrong.