Skip to content

Instantly share code, notes, and snippets.

@Cyberloki
Cyberloki / API.md
Created April 7, 2017 03:23 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@Cyberloki
Cyberloki / png_sprite_with_transparency
Created October 9, 2013 21:55
PNG Sprite with transparency Create a Sprite set (vertical set of multiple images) with a CSS reference for use in Icenium for instance
Make sure the individual PNG images have transparency
http://watermark.algid.net/en/create-transparent-png.php
Pack the images into a sprite png, and get the CSS
http://cly.jsser.com/sprites/
Make buttons
http://dabuttonfactory.com/
http://cooltext.com/
C# Regular Expressions Cheat Sheet
Cheat sheet for C# regular expressions metacharacters, operators, quantifiers etc
Character
Description
\
@Cyberloki
Cyberloki / RegEx_CSV_Record_Fields
Created October 4, 2013 02:11
RegEx CSV Record fields Uses a regex to pick out the fields the delimiter and "quote" is passed in also You can then reference each "field" using the public "Fields" property Otherwise, you can use the GetResultsFromExpression() method which accepts field references such as {{1}} for field 1 or {{2}} for field 2 Therefore you can combine multipl…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace EDI.Import
{
public class CSVRecord
{
@Cyberloki
Cyberloki / Working with AsyncTasks on Android.java
Created September 26, 2013 22:41
Working with AsyncTasks on Android
Working with AsyncTasks on Android
from category Android
Introduction
Developing Android applications is a lot of fun because it offers a lot of possibilities to implement one's own ideas. Frequently i have to use AsyncTasks to do heavy work aside the ui thread. In the following i give a quick overview on AsyncTasks and provide some code snippets that might be useful for everyday development with Android regarding the use of AsyncTasks.
Lifecycle
An AsyncTask in Android is used to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers (more information). The structure follows call onPreExecute() for preparation, doInBackground() for doing the main task and return its result finally to the onPostExecute() method. Optional you can implement the onProgressUpdate() method e.g. to show a progressbar.
The following example can be used as template for an AsyncTask.
private class MyTask extends AsyncTask<Object, Void, Object> {
@Cyberloki
Cyberloki / Check if SQLDataReader has field or field is null
Created September 22, 2013 23:05
C# Check if SQLDataReader has field or field is null
// assumes dr is a SqlDataReader
List<string> columns_ = GetColumns(dr);
if (columns_.IndexOf("MissingField") == -1) { throw new Exception("Query did not contain \"MissingField\""); }
this.DBID = (int)dr["ID"];
this.Created = (DateTime)dr["Created"];
this.DataText = (string)dr["MissingField"];
if (!dr.IsDBNull(columns_.IndexOf("MsgType")) { this.MsgType = (string)dr["MsgType"]; }
@Cyberloki
Cyberloki / SQL AsXMLAttribute function.sql
Created September 22, 2013 22:51
SQL AsXMLAttribute function
if object_id('AsXMLAttribute') IS NOT NULL
DROP FUNCTION [dbo].[AsXMLAttribute]
GO
CREATE FUNCTION [dbo].[AsXMLAttribute] (
@text varchar(max)
)
RETURNS varchar(max)
AS
BEGIN
@Cyberloki
Cyberloki / select into_Insert into.sql
Created September 22, 2013 21:53
Create a new table dynamically and insert records (Select Into) Copy records into existing table (Insert Into)
-- create a new table and insert records
-- =====================================
select * into newtablename from MyFirstTable
-- copy records into existing table
-- =====================================
insert into ReprocessTable(event_time, [msg]) select event_time, [msg] from FailedTable order by [id]
-- create a new table with records from another database
@Cyberloki
Cyberloki / Search all stored procedures and functions etc for specific text.sql
Created September 22, 2013 21:49
Search all stored procedures and functions etc for specific text
select so.name, sc.[text]
from syscomments sc with (nolock)
inner join sysobjects so with (nolock) on so.[id] = sc.[id]
where [text] like '%create_job%'
/* raw
select * from syscomments sc with (nolock) where [text] like '%create_job%'
*/
@Cyberloki
Cyberloki / Find Large MSSQL Database tables by tablesize.sql
Created September 22, 2013 21:46
Find Large MSSQL Database tables by tablesize
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id