View foo.js
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 Ros object, wrapping a web socket connection to rosbridge. | |
var ros = new ROSLIB.Ros({ | |
url: 'ws://localhost:9090' // url to your rosbridge server | |
}); | |
//* A topic for messaging. | |
var exampleTopic = new ROSLIB.Topic({ | |
ros: ros, | |
name: '/com/endpoint/example', // use a sensible namespace | |
messageType: 'std_msgs/String' |
View readBytesFullArraySize.java
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
package com.example; | |
import java.io.IOException; | |
import java.util.Arrays; | |
class MyTestClass | |
{ | |
public static void main(String[] args){ | |
byte[] bytes = new byte[30]; |
View readBytesWithLength.java
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
import java.io.IOException; | |
import java.util.Arrays; | |
public class InputStreamExample { | |
public static void main(String[] args){ | |
byte[] bytes = new byte[30]; | |
try { | |
System.out.println("Available bytes :"+System.in.available()); |
View input_key_compare.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
# Use 0xFF to AND output the only 8bits for a char. | |
if cv2.waitKey(0) & 0xFF == ord('q'): | |
break | |
View check_consecutive_ones.cpp
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
// https://www.hackerrank.com/challenges/30-binary-numbers/problem | |
using namespace std; | |
int main(){ | |
int n; | |
cin >> n; | |
int count = 0; | |
int old = 0; |
View getline_input.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
#!/bin/python3 | |
import sys | |
if __name__ == "__main__": | |
n = int(input().strip()) | |
m = int(input().strip()) | |
for a0 in range(m): | |
x, y, w = input().strip().split(' ') | |
x, y, w = [int(x), int(y), int(w)] |
View line_input_to_array.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
# Sample Input | |
# ( you dont need the count number for python) | |
# 1 2 3 4 10 11 | |
number_of_elements = int(raw_input()) | |
array = map(int, raw_input().split()) | |
print sum(array) |
View compare_triplet.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
# a nice example where you can use zip to compose pair together to compute them | |
a_triplet = map(int, input().split()) | |
b_triplet = map(int, input().split()) | |
alice_points = 0 | |
bob_points = 0 | |
for a_val, b_val in zip(a_triplet, b_triplet): | |
if a_val < b_val: | |
bob_points += 1 | |
elif a_val > b_val: |
View decimal_prints.cpp
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 namespace std; | |
int main() { | |
int n; | |
cin >> n; | |
double pl = 0, mn = 0, zr = 0; | |
for (int i = 0; i < n; i++) { | |
int val; |
View isValidBST.cpp
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
#include <iostream> | |
#include <climits> | |
struct TreeNode { | |
int val; | |
TreeNode* left; | |
TreeNode* right; | |
TreeNode(int x): val(x), left(nullptr), right(nullptr) {} | |
}; |
OlderNewer