Skip to content

Instantly share code, notes, and snippets.

View Bloofer's full-sized avatar

Joonmo Yang Bloofer

View GitHub Profile
@Bloofer
Bloofer / Constant folding step3
Created January 4, 2018 07:18
Constant folding step3
int c;
c = 12;
if (true) {
c = 2;
}
return c * 2;
@Bloofer
Bloofer / Constant folding result
Created January 4, 2018 07:19
Constant folding result
return 4;
@Bloofer
Bloofer / Deckard config
Created January 8, 2018 06:32
Deckard config
#############################################################
# Configuration file for clone detection.
#
############################################################
# Often, need to change these common parameters:
# - FILE_PATTERN : for source files in different languages
# - SRC_DIR : the root directory containing the source files
# - DECKARD_DIR : Where is the home directory of DECKARD
# - clone detection parameters: c.f. DECKARD's paper
@Bloofer
Bloofer / Deckard clone snippet #1
Created January 8, 2018 08:38
Deckard clone snippet #1
private int getDefaultRowSize() {
int rowSize = DebugUITools.getPreferenceStore().getInt(IDebugPreferenceConstants.PREF_ROW_SIZE);
int bytePerLine = rowSize * getAddressableSize();
// check synchronized row size
Integer size = (Integer)getSynchronizedProperty(AbstractAsyncTableRendering.PROPERTY_ROW_SIZE);
if (size != null)
{
// row size is stored as actual number of bytes in synchronizer
@Bloofer
Bloofer / Deckard clone snippet #2 - AbstractAsyncTableRendering.java
Created January 8, 2018 08:45
Deckard clone snippet #2 - AbstractAsyncTableRendering.java
if (data instanceof MemorySegment) {
MemorySegment line = (MemorySegment) data;
if (col > 0) {
int start = (col - 1) * getBytesPerColumn();
int end = start + getBytesPerColumn();
MemoryByte[] bytes = line.getBytes(start, end);
String str = getToolTipText((BigInteger)address, bytes);
@Bloofer
Bloofer / Deckard clone snippet #2 - AbstractTableRendering.java
Created January 8, 2018 08:47
Deckard clone snippet #2 - AbstractTableRendering.java
if (address != null) {
Object data = item.getData();
if (data instanceof TableRenderingLine) {
TableRenderingLine line = (TableRenderingLine) data;
if (col > 0) {
int start = (col - 1) * getBytesPerColumn();
int end = start + getBytesPerColumn();
MemoryByte[] bytes = line.getBytes(start, end);
@Bloofer
Bloofer / mismatch.ml
Created January 23, 2018 08:55
mismatch.ml
open Core.Std
let find_mismatches map1 map2 =
Map.to_sequence map1
|> Sequence.filter_map ~f:(fun (key, data) ->
match Map.find map2 key with
| None -> None
| Some data' ->
if data' <> data then Some key
else None
@Bloofer
Bloofer / mismatch.py
Created January 23, 2018 08:56
mismatch.py
def find_mismatches(d1,d2):
mismatches = [];
for (key,data) in d1.items():
if data != d2[key]:
mismatches.append(key)
return mismatches
@Bloofer
Bloofer / expect_test.ml
Created April 13, 2018 07:10
expect test
let%expect_test _ =
let test l =
let stringify l = List.map ~f:Int.to_string |> String.concat ~sep:"-" in
List.group l ~break:(fun x y -> y < x)
|> List.iter ~f:(fun sub -> print_endline (stringify sub))
in
test [1;2;3;2;3;3;6;1;2;36;7];
[%expect {|
1-2-3
2-3-3-6
@Bloofer
Bloofer / bad_assign.c
Created June 29, 2018 07:57
bad assign
int a, b = 0;
bool t, f = false;