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
Using Select(): a power of LINQ for casting datatable into List of Object | |
List<Student> target = dt.AsEnumerable() | |
.Select(row => new Student | |
{ | |
// assuming column 0's type is Nullable<long> | |
StudentID = row.Field<long?>(0).GetValueOrDefault(), | |
StudentName = String.IsNullOrEmpty(row.Field<string>(1)), | |
}).ToList(); |
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
var gcm = require('node-gcm'); | |
var notify = exports; | |
notify.send = function(msg, reg_id) { | |
var message = new gcm.Message(); | |
message.addData('msg', msg); | |
// get token here | |
// TODO | |
//var regTokens = ['APA91bFiJx52Iq2_LwyXPUWeO0Vg-9DmrWW6E6BmjwNUtTIrWRNOIDzaCmOidzndjZE3zWvL248GtqBYIV7YsD9q37M0urFz3FD6DvYkOaVqJqV3V9CciPletqzbJqvEm-54cpwMNcxP']; |
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
WARNING: its hard reset, means all the data or log will be removed | |
To reset the django migration to initial follow following order | |
* Remove database | |
* Remove all the contents of django app's migrations folder except __init__.py file. | |
* The remaining migrations folder should be something like | |
myapp | |
├── migrations | |
│ │ ├── __init__.py |
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
// Found somewhere in website, and updated. | |
#include <SoftwareSerial.h> | |
SoftwareSerial RFID(2, 3); // RX and TX | |
int data1 = 0; | |
int ok = -1; | |
int yes = 13; | |
int no = 12; |
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
# DJango Template Tags Cheat Sheet | |
## Inheritance and Inclusion | |
{% extends "base.html "%} | |
{% block content %} ... {% endblock %} or {% block content %} ... {% endblock content %} | |
{% include "foo/bar.html" %} | |
{% ssi /home/html/ljworld.com/includes/right_generic.html %} | |
## Filters and Tags |
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 Timer(){ | |
final Handler ha=new Handler(); | |
ha.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
Debug.Log("Calling data"); | |
// call your function | |
ha.postDelayed(this, 20*1000); | |
} |
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
SRC: http://pmt.sourceforge.net/pngcrush/ | |
Issue fixes for : #AAPT: *.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited | |
Use pngcrush to remove the incorrect sRGB profile from the png file: | |
pngcrush -ow -rem allb -reduce file.png | |
-ow will overwrite the input file | |
-rem allb will remove all ancillary chunks except tRNS and gAMA | |
-reduce does lossless color-type or bit-depth reduction |
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
# lastb : Unsuccessful attempts | |
# last : Successful attempts | |
sudo lastb | sed 's/ \+/ /g'| cut -d' ' -f3 | sort | uniq -c | sort -n | |
sudo last | sed 's/ \+/ /g'| cut -d' ' -f3 | sort | uniq -c | sort -n |
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
If we need to make usb stick bootable of windows ISO follow the steps | |
``` | |
$ sudo apt-get install winusb | |
``` | |
run winusb comand with appropiate parameters | |
``` | |
$ sudo winusb --format <ISO file> <desk> | |
``` | |
Example | |
``` |
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
# OS: Ubuntu | |
## Basic Configuration | |
-- login using ssh | |
# ssh root@IP | |
-- Update latest updates/security patches | |
-- set timezone | |
# timedatectl set-ntp true | |
# dpkg-reconfigure tzdata | |
-- Add new user - |