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
#define GET_BIT(X,N) ( ( (X) >> (N) ) & 1 ) | |
#define SET_BIT(X,N) ( (X) | (1 << (N) ) ) | |
#define RST_BIT(X,N) ( (X) & ~(1 << (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
/* | |
* This function prints hex dump of memory specified as a pointer. | |
* Reference: http://stackoverflow.com/questions/7775991/how-to-get-hexdump-of-a-structure-data | |
*/ | |
#include <stdio.h> | |
void hexDump(char *desc, void *addr, int len) | |
{ | |
int i; | |
unsigned char buff[17]; |
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 function calculates a checksum of ip header. | |
* Reference: http://www.microhowto.info/howto/calculate_an_internet_protocol_checksum_in_c.html | |
*/ | |
uint16_t ip_checksum(void* vdata, size_t length) | |
{ | |
// Cast the data pointer to one that can be indexed. | |
char* data=(char*)vdata; |
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
<snippet> | |
<content><![CDATA[ | |
#ifndef ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g} | |
#define ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g} | |
$0 | |
#endif // ${TM_FILEPATH/(([A-Za-z]+)\/src\/)|./\U(?1:$2_)\E/g}${TM_FILENAME/(([A-Z])([A-Z][a-z]))|(([a-z])([A-Z]))|([a-z])|(\.)/\U(?1:$2_$3)(?4:$5_$6)$7(?8:_)\E/g} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> |
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
<snippet> | |
<content><![CDATA[ | |
#ifdef DEBUG | |
#endif // DEBUG | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>ifdebug</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<scope>source.c++, source.c</scope> | |
</snippet> |
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
/* | |
An example of using raw sockets. | |
You can capture packets by tcpdump: | |
tcpdump -X -s0 -i lo -p udp | |
*/ | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> |
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
# The MIT License (MIT) | |
# Copyright (c) 2016 Leonid Edrenkin | |
# | |
#!/bin/bash | |
case "$2,$3" in | |
message,HEAD) | |
;; | |
*) |
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
# The MIT License (MIT) | |
# Copyright (c) 2016 Leonid Edrenkin | |
# | |
# This is a Sublime Text 3 plugin that makes an adjusted multiline C-macro. | |
# You should select some code and apply one of commands: | |
# view.run_command('make_multi_line_macro') | |
# view.run_command('unmake_multi_line_macro') | |
import sublime, sublime_plugin |
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
# The MIT License (MIT) | |
# Copyright (c) 2016 Leonid Edrenkin | |
# | |
# This is a Sublime Text 3 plugin that makes and unmakes a numberred list. | |
# You should select text lines and apply one of commands: | |
# view.run_command('make_numberred_list') | |
# view.run_command('unmake_numberred_list') | |
import sublime, sublime_plugin |
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
# The MIT License (MIT) | |
# Copyright (c) 2016 Leonid Edrenkin | |
# | |
# This is a Sublime Text 3 plugin that copies selected lines to the clipboard. | |
# You should select text lines and apply command: | |
# view.run_command('copy_lines_to_clipboard') | |
# view.run_command('copy_lines_to_clipboard', {"with_filename": True}) | |
# view.run_command('copy_lines_to_clipboard', {"with_filename": True, "tabsize" : 4}) |
OlderNewer