Skip to content

Instantly share code, notes, and snippets.

@appforest
appforest / cosasPorHacer_1.html
Created June 23, 2014 01:36
Lista de Cosas Por Hacer - Tutorial - Parte 1
<!DOCTYPE HTML>
<html lang="en" ng-app="cosasPorHacer">
<body ng-controller="cosasPorHacer_Ctrl">
<!-- Recuerda usar la librería más reciente disponible (al menos mientras llegue una nueva versión de angular que cambie todo) -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.17/angular.min.js"></script>
<script>
// Declaramos la apliacaión con el nombre 'cosasPorHacer' con un array vacío '[]' y la asociamos a la variable 'aplicacion'
var aplicacion = angular.module('cosasPorHacer', []);
@appforest
appforest / cosasPorHacer_2.html
Created June 23, 2014 01:35
Lista de Cosas Por Hacer - Tutorial - Parte 2
<!DOCTYPE HTML>
<html lang="en" ng-app="cosasPorHacer">
<body ng-controller="cosasPorHacer_Ctrl">
<!-- ng-submit se dispara cuando el formulario se envía (bien sea por el accionar de la tecla Enter o por clic sobre el botón "Enviar"); ejecutará "agregarElemento" es el nombre de la función que inserta elementos en el array "$scope.listaDeCosas". -->
<form ng-submit="agregarElemento()">
<!-- La propiedad ' ng-model="cosaPorHacer" ' del input hace que Angular pueda tomar su valor desde el controlador. Angular se debe referir a este modelo usando "$scope.cosaPorHacer" -->
<input type="text" ng-model="cosaPorHacer" placeholder="Agregar nueva cosa por hacer">
<input type="submit">
</form>
@appforest
appforest / sublimeHTML_Snippet.html
Created February 2, 2014 19:10
Sublime HTML base snippet
<snippet>
<content><![CDATA[<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$1</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="css/styling.css">
</head>
<body>
@appforest
appforest / cs_datareader
Created January 5, 2014 17:26
Writing data to a variable from a DB query using a SqlDataReader
[WebMethod]
public static string GetValues2(string value)
{
string CS = ConfigurationManager.ConnectionStrings["test_connectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
con.Open(); // The connection needs to be explicitly opened in order to use the SqlDataReader.
SqlCommand cmd = new SqlCommand("SELECT * FROM something WHERE somethingId = 2", con);
using (SqlDataReader rdr = cmd.ExecuteReader()) // Cannot be instantiated with the 'new' operator. Needs an open connection.
{
@appforest
appforest / pageMethods
Created January 5, 2014 02:44
PageMethods & Webmethods (JS & C#)
// Thanks to Enrico Ariel @ http://www.youtube.com/watch?v=Kp4jxrs6uuI
//The codebehind:
[WebMethod]
public static string GetValues(string value)
{
value = value +" - Sent @ " + DateTime.UtcNow.ToLongTimeString();
return value;
}
@appforest
appforest / cs_dataset-sp
Created January 5, 2014 01:53
C# - Calling a Stored Procedure. Using a dataset to get the data.
string CS = ConfigurationManager.ConnectionStrings["test_connectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlDataAdapter da = new SqlDataAdapter("testProcedure3", con); // Using a Store Procedure.
//SqlDataAdapter da = new SqlDataAdapter("SELECT 'this is a test text' as test", con); To use a hard coded query.
da.SelectCommand.CommandType = CommandType.StoredProcedure; // Comment if using hard coded query.
DataSet ds = new DataSet(); // Definition: Memory representation of the database.
da.SelectCommand.Parameters.AddWithValue("@ggg", 95); // Repeat for each parameter present in the Store Procedure.
da.Fill(ds); // Fill the dataset with the query data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using connection As New SqlConnection("Data Source=***SQL-SERVER-LOCATION***;Initial Catalog=***DB-NAME***;Integrated Security=True")
connection.Open()
Dim command As New SqlCommand("SELECT * FROM ***TABLE-NAME***", connection)
Dim reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
@appforest
appforest / jsCopy
Created September 3, 2013 19:18
Copy to Clipboard
function copyToClipboard(){
var textoCopiable = document.body.createTextRange();
textoCopiable.moveToElementText(document.getElementById("toCopyFrom"));
textoCopiable.select();
textoCopiable.execCommand("Copy");
textoCopiable.execCommand("unselect");
}