Skip to content

Instantly share code, notes, and snippets.

View ahdidou-mohamed's full-sized avatar

Mohamed AHDIDOU ahdidou-mohamed

View GitHub Profile
@ahdidou-mohamed
ahdidou-mohamed / measure-execution-time-elegantly-using-measuretimedvalue.kt
Last active April 24, 2022 17:05
Measure execution time elegantly using measureTimedValue
import kotlin.time.ExperimentalTime
import kotlin.time.measureTimedValue
@OptIn(ExperimentalTime::class)
fun main() {
val (value, time) = measureTimedValue {
longOperation()
}
println("LongOperation took $time to calculate $value ")

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@ahdidou-mohamed
ahdidou-mohamed / MainActivity.kt
Created April 25, 2021 00:06 — forked from webserveis/MainActivity.kt
Implementar click RecyclerView Kotlin AndroidX
val mAdapter = MySimpleAdapter(dummyData())
recycler_view.setHasFixedSize(true)
recycler_view.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
recycler_view.adapter = mAdapter
mAdapter.setOnItemClickListener(object : MySimpleAdapter.ClickListener {
override fun onItemClick(v: View, position: Int) {
Log.v(TAG, "onItemClick ${position}")
@ahdidou-mohamed
ahdidou-mohamed / in_viewport.js
Created January 17, 2018 16:10 — forked from jjmu15/in_viewport.js
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@ahdidou-mohamed
ahdidou-mohamed / Install Ruby
Created January 20, 2017 16:19
How to install ruby in Ubuntu 14.04 LTS
#Step 1
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
#Step 2
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
@ahdidou-mohamed
ahdidou-mohamed / [email protected]
Created March 22, 2016 17:50 — forked from uebo/[email protected]
iOS Sample Launch Screen File
Default-568h@2x.png
public void post(Context context, JSONObject params,String url) {
ByteArrayEntity entity;
try {
entity = new ByteArrayEntity(params.toString().getBytes("UTF-8"));
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
mHTTPClient.post(context, url, entity, "application/json", this);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//Type de recours
NSDictionary * dict1 = [NSDictionary dictionaryWithObjectsAndKeys:@"CID Réel",@"value",@"$CIR",@"key", nil];
NSDictionary * dict2 = [NSDictionary dictionaryWithObjectsAndKeys:@"CID Forfaitaire",@"value",@"$CIF",@"key", nil];
NSDictionary * dict3 = [NSDictionary dictionaryWithObjectsAndKeys:@"Hors CID",@"value",@"$HCI",@"key", nil];
//Original/Adaptable
NSDictionary * dict1 = [NSDictionary dictionaryWithObjectsAndKeys:@"Oui",@"value",@"O",@"key", nil];
NSDictionary * dict2 = [NSDictionary dictionaryWithObjectsAndKeys:@"Non",@"value",@"N",@"key", nil];
NSString * html = [NSString stringWithFormat:@"<html><head></head><body style='font-family: WinstonMedium; margin: 0; padding: 0; '><p><img src=\"%@\"style=\"width:320px; margin:0px\" /></p><h3 style='margin: 10px; padding: 0; color:#AA0D1A'>%@</h3><h4 style='margin: 10px; padding: 0;color:#09274E'>Publi&eacute; le %@</h4><div style='margin: 10px; padding: 0;'>%@</div></body></html>",[MEDIA_BASE_URL stringByAppendingString:[self.article objectForKey:@"miniature"]],[self.article objectForKey:@"title"],[NOVUtils stringFromDate:[NSDate dateWithTimeIntervalSince1970:[[self.article objectForKey:@"created_at"] intValue]]], [self.article objectForKey:@"content"]];
html = [html stringByReplacingOccurrencesOfString:@"font-family: Calibri;" withString:@"font-family: WinstonMedium;"];
-(void)startPostRequest:(NSString *)url params:(NSDictionary *)params{
[self.delegate networkStared:self];
NSLog(@"POST URL : %@", url);
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/html", nil];