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
CREATE OR REPLACE function join ( p_cursor sys_refcursor, p_del varchar2 := '; ' ) | |
return varchar2 is l_value varchar2(32767); | |
l_result varchar2(32767); | |
begin loop fetch p_cursor into l_value; | |
exit when p_cursor%notfound; | |
if l_result is not null then | |
l_result := l_result || p_del; | |
end if; | |
l_result := l_result || l_value; | |
end loop; |
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
[WebMethod] | |
public string GetPicture() { | |
// Load the picture | |
Image img = Image.FromFile("Path/To/Picture.jpg"); | |
// Create a memory stream, and put the image contents into it. | |
MemoryStream stream = new MemoryStream(); | |
img.Save(stream, img.RawFormat); | |
// return data, encoded in Base64 | |
return Convert.ToBase64String(stream.ToArray()); | |
} |
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
private void LoadImage() { | |
// Create web service | |
WebServiceSoapClient service = new WebServiceSoapClient(); | |
// Fetch encoded image using the web service method | |
string encodedImage = service.GetPicture(); | |
// turn the Base64 string back into bytes | |
byte[] buffer = Convert.FromBase64String(encodedImage); | |
// create a stream from the data | |
MemoryStream stream = new MemoryStream(buffer, false); | |
// recreate Image object, and display it in pictureBox1 |
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
public List<String> GetFirstNames(string surname) { | |
List<String> names = new List<String>(); | |
using (SqlConnection con = new SqlConnection(<connection string>)) { | |
using (SqlCommand cmd = new SqlCommand("SELECT firstname FROM People WHERE surname=@surname", con)) { | |
cmd.Parameters.AddWithValue("@surname", surname); | |
SqlDataReader reader = cmd.ExecuteReader(); | |
while (reader.Read()) { // while there is data | |
string name = reader["firstname"].ToString(); // for other data, use Convert.ToInt32() etc | |
names.Add(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
#!/usr/bin/python | |
# | |
# Sandbox dnsmasq setup script | |
# | |
# Jak Spalding <[email protected]> | |
# 2012-03-03 | |
# | |
# for Python 2.4 | |
import re |
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
<?php | |
function pluralise($count, $single, $plural = null) { | |
if ($count == 1 || $count == -1) { | |
return $single; | |
} | |
if ($plural == null) { | |
$plural = $single . 's'; | |
} | |
return $plural; |
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
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location = /index.php { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} |
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
openssl pkcs12 -in myfile.p12 -out newfile.pem -nodes |
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
def guess_name(name) | |
md = /([\w\.]+)\.(\d{4})\..*/i.match(name) | |
moviename = md[1].gsub(/\./, ' ') | |
year = md[2] | |
"#{moviename} (#{year})" | |
end |
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
› diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://4194304` # Create a 2GB ramdisk | |
› rsync -avr Code/ /Volumes/RAM\ Disk/ # Copy your work over | |
› open /Volumes/RAM\ Disk/ # Open in Finder | |
# Change ram://XXXX to MB required x 2048 (4194304 = 2048 x 2048) | |
# 1GB = 2097152 | |
# 2GB = 4194304 | |
# 3GB = 6291456 | |
# 4GB = 8388608 | |
# 8GB = 16777216 |
OlderNewer