Skip to content

Instantly share code, notes, and snippets.

View Nallo's full-sized avatar
:fishsticks:

Stefano Martinallo Nallo

:fishsticks:
View GitHub Profile
import XCTest
func assert<T: Equatable>(_ json: Data, hasKey expectedKey: String, andValue expectedValue: T, at index: Int = 0, file: StaticString = #filePath, line: UInt = #line) {
guard let json = try? JSONSerialization.jsonObject(with: json) as? [String: Any] else {
return XCTFail("input is not a valid json object", file: file, line: line)
}
guard let receivedValue = json[expectedKey] as? T else {
return XCTFail("json has no key \"\(expectedKey)\"", file: file, line: line)
}
XCTAssertEqual(
var natPolicy = linphone_core_get_nat_policy(lc)
Log.d("ice_enabled " + linphone_nat_policy_ice_enabled(natPolicy))
Log.d("stun_enabled " + linphone_nat_policy_stun_enabled(natPolicy))
Log.d("get_stun_server " + linphone_nat_policy_get_stun_server(natPolicy))
Log.d("turn_enabled " + linphone_nat_policy_turn_enabled(natPolicy))
Log.d("tcp_turn_transport_enabled " + linphone_nat_policy_tcp_turn_transport_enabled(natPolicy))
Log.d("udp_turn_transport_enabled " + linphone_nat_policy_udp_turn_transport_enabled(natPolicy))
Log.d("tls_turn_transport_enabled " + linphone_nat_policy_tls_turn_transport_enabled(natPolicy))
@Nallo
Nallo / main.dart
Created October 2, 2020 06:28
Flutter - Update textfield programmatically
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@Nallo
Nallo / regex.dart
Last active October 1, 2020 12:13
Dard Regex
void main() {
String s1 =
'./values-IT/strings.xml:374: <string name="accepted-terms">Termini "accettati" <ok> ciao</string>';
RegExp regExp = RegExp(r'^(.*)\s+<string name="(.*)">(.*)<\/string>');
Iterable<Match> matches = regExp.allMatches(s1);
for (Match match in matches) {
print("input --> ${match.group(0)}");
int count_ones(unsigned long long n) {
int ones = 0;
while(n != 0) {
bool is_one = (n & 1UL) == 1UL;
if (is_one) {
ones++;
}
n = n >> 1;
}