teleren/devto huggingface dataset:
Use obj-c method swizzling in GoMobile iOS games
Tags: gomobile, ios, gamdev
Published: 2018-10-02 07:34:45

---
title: Use obj-c method swizzling in GoMobile iOS games
published: true
description: 
tags: gomobile,ios,gamdev 
---

We have used gomobile to develop games for Android and iOS. But it's not easy to add new features like integrating Ads/Analytics. On Android, we can just unpack the Apk built with gomobile and use the `.so` directly in a new android project. But on iOS, it's impossible.  I have written a post about how to integrate ads SDK weeks ago, you can found it [here](https://dev.to/ntoooop/port-a-golang-game-to-ios-p2c). In the post, I changed the gomobile's source code and patched with two hook method. These days, I found a new way, need no change of the source code, it's the magic of Object-C, called *Method Swizzling*.

Method swizzling provide a way to exchange the implementation a method, so, you can use it to add new feature to an existing class. Here is what we do:

```
@implementation GoAppAppController(AD)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = [self class];
        
        SEL originalSelector = @selector(viewDidLoad);
        SEL swizzledSelector = @selector(kkViewDidLoad);
        
        Method originalMethod = class_getInstanceMethod(class, originalSelector);
        Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
        
        BOOL success = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
        if (!success) {
            method_exchangeImplementations(originalMethod, swizzledMethod);
        }
    });
}


- (void)kkViewDidLoad {
    [self kkViewDidLoad];
    
    // Initialize Google Mobile Ads SDK
    [GADMobileAds configureWithApplicationID:@"..."];
}
```

In the `+ (void)load` method, I use method swizzling to exchange the implementation of `GoAppAppController`'s viewDidLoad method and my `kkViewDidLoad` method. `GoAppAppController` is gomobile's implementation of UIViewController, you can found the source code in `x/mobile/app/darwin_ios.m`. In `kkViewDidLoad` method, I call `[self kkViewDidLoad]` to invoke the original `viewDidLoad` , than, call `GADMobileAds` to initialize my Admob Ads SDK. 

That's all, it's very concise and easy! I also used it in my second game *Unstable Tower*, but, unfortunately, Apple say it's alike existing game in AppStore, so it did not pass the review. There is also an Android version, if you like it, you can download it in [GooglePlay](https://play.google.com/store/apps/details?id=io.korok.unstabletower).
Domain Search and .tr Domain Document
Published: 2018-10-02 06:13:17

---
title: Domain Search and .tr Domain Document
published: true
description: With Domain Sorgulama (Domain Search) System, you can easily identify and register the domain you are looking for.
tag: domain, domain search
---

With Domain Inquiry you can review the registration status for the domain you want to buy. Domain; The website is the beginning to open. The names of the websites used to log on to the Internet are called domains. Domain registration can be done in person or corporation for small fees. Once the domain is questioned, it can be registered if it is available and it can be started with the hosting package to start creating websites.

## Domain Registration

The domain address that is available is registered as [domain registrar](https://domain.ahmetcadirci.com/). The registered domain addresses are registered between 1 year and 10 years. Domain registration for the duration of the end of the period of the right to extend the domain for the duration of 37 days domain belongs to the owner.

With [Domain Sorgulama](https://domain.ahmetcadirci.com/) (Domain Search) System, you can easily identify and register the domain you are looking for. No domain queries can be viewed by anyone unless you register for security and privacy. Domain registration should definitely be done on a corporate firm, otherwise, you cannot claim any rights when you cannot reach that person in the domain addresses registered on a person.

In extension and name selection, com extension is the most preferred extension; If it is full, the document should be obtained in .tr. If these extensions are full and you don't want to change your brand name, our site lists the most preferred extensions from left to right.
You can pass variable arguments in a Kotlin function
Tags: kotlin, beginners
Published: 2018-10-02 04:35:33

---
title: You can pass variable arguments in a Kotlin function
published: true
tags: kotlin, beginner
canonical_url: https://www.workingdev.net/2018/10/kotlin-variable-arguments-in-functions.html
cover_image: https://thepracticaldev.s3.amazonaws.com/i/u79iwq3v8iftxkz1a7pr.jpg
description: You can pass variable number of arguments in a Kotlin function. See how it's done
---

Functions in Kotlin, like in Java, can also accept an arbitrary number of arguments.  The syntax is a bit different from Java, instead of using three dots after the type `...` , we use the `vararg` keyword instead. 

```kotlin
fun<T> manyParams(vararg va : T) {  // (1)
  for (i in va) { // (2) 
    println(i)
  }
}

fun main(args: Array<String>) {
  manyParams(1,2,3,4,5)  // (3)
  manyParams("From", "Gallifrey", "to", "Trenzalore")  // (4) 
  manyParams(*args) // (5) 
  manyParams(*"Hello there".split(" ").toTypedArray()) // (6)
}
```

**(1)** The vararg keyword lets us accept multiple parameter for
this function. In this example, we declared a function that has a typed
parameter; it’s generic. We didn’t have to declare it as generic in order to
work with variable arguments, we just chose to so that it can work with a
variety of types

**(2)** This is a simple looping mechanism so that we can print each item in the argument

**(3)** We can pass Ints, and we can pass as many as we want because manyParams accepts variable number of arguments

**(4)** It works with Strings as well

**(5)** Like in Java, we can pass an array to a function that accepts variable arguments. We need to use spread operator * to unpack the array. It’s like passing the individual elements of the array one by one, manually

**(6)** The split() member function will return an *ArrayList*, you can convert it to an *Array* , then use the spread operator so you can pass it to a *vararg* function

 ![](http://feeds.feedburner.com/~r/WorkingDev/~4/Nw_buFAs-sM)
Play videos inline in HTML5 video player on iOS
Tags: html, cordova, videojs, javascript
Published: 2018-10-02 04:23:06

---
title: Play videos inline in HTML5 video player on iOS
published: true
description: 
tags: HTML5, Cordova, VideoJS, JavaScript
---

To give a background. We were using an older version of [VideoJS](https://videojs.com/) (5.4.4) which does not prevent videos from playing in the native iOS video player like in the below image. So we did not have any control over the playing video.


![iOS video player](http://cdn.iphonehacks.com/wp-content/uploads/2017/06/iOS-10-vs-iOS-11-Video-player.jpeg)

Image courtesy - http://www.iphonehacks.com

With iOS 12 release, our mobile app which was developed in Cordova crashed every time the user exit from fullscreen. 

We analysed the issue and were able to find a solution to force videos to play inline inside the application instead of letting iOS take control over the video.

Add *playsinline* or *webkit-playsinline* to your HTML5 video tag. And go to your Cordova config.xml file and add the following preference for iOS platform.

~~~~
<preference name="AllowInlineMediaPlayback" value="true"/>
~~~~~~~~

Now when we built our application we were successful in preventing the video from playing in native player but we could see the native controls on the video player and on clicking it the user could still switch to iOS native video player. We tried adding all possible css styles suggested on different forums and stackoverflow but those did not help. We finally had to upgrade to latest VideoJS version in which the native controls were hidden. 


Hope this article is helpful.
Looking for an internship at NYC for a year! 
Tags: internship, newyorkcity, nyc, frontend
Published: 2018-10-02 01:12:18

---
title: Looking for an internship at NYC for a year! 
published: true
description: 
tags: internship, new york city, nyc, front-end
---

I AM SO STOKED YALL. I got accepted into my school's programme which lets me work at NYC for A YEAR. I am going to be situated there from the first week of Jan 2019 to Dec 2019. 

Am so stoked because even though I originally wanted to go to SV instead, NYC is great too!!! I'm gonna have my fill of streetwear there :P

If anyone has internship positions open for front-end dev in 2019, HMU! I am still in the midst of rewriting my online resume site (because it's sort of a requirement to follow a template given to us by the programme manager, things like writing out modules I took in school which may be relevant to my internship, and writing a narrative of what i can contribute to startups etc). But I do have a pdf resume & github.io link to my existing portfolio ready.

Meanwhile, I have been super busy coding for projects in school, using Angular & Ionic. Been learning a couple of new stuff about the intricacies of javascript and angular 2+ itself that I'd post up soon :D
packages "cache" and symlink all the projects?
Tags: help, npm, discuss
Published: 2018-10-02 04:22:57

---
title: packages "cache" and symlink all the projects?
published: true
tags: help, npm, discuss
---

Hi everyone! I started to think about that question two months ago as I'm working in different projects and my 256Gb SSD is running out of space. 

I know I can use **npm link**, but I'm looking for a package manager that can install a package **only in one folder** and then resolve required packages as symlinks into the working directory. E.g. `npm-symlink install --save-dev electron`

What do you think? Would be a good idea? I will give it a try with python.
Live unit test
Tags: productivity, unittests
Published: 2018-10-02 02:10:41

---
title: Live unit test
published: true
description: real time feedback
tags: productivity, unit tests
---

I want to introduce you to the live code test, from Visual studio 2017.

Is a great idea for produce without stop every time to execute tests or even debugg your code.

The live test unit, run your unit test in the background, every time you modify your code being tested, you are notified when your test fails and when tests performed successfully (which is indicated by the green check mark, "✓"),


![example of real time test](https://thepracticaldev.s3.amazonaws.com/i/rltlri2atpj92htalbfa.png)

the live tests indicates when an line of your code is note covered in tests.

Maybe you are think, is not too heavy? yes, is so... but it is a great helper, and it can save some time during coding.

 I hope to see features like this in another IDEs, or even in Editor (Visual code plzzz) hahahahaha
A consideration on URL encoding when posting a tweet on the Twitter platform
Tags: twitter, api
Published: 2018-10-02 01:58:09

---
title: A consideration on URL encoding when posting a tweet on the Twitter platform
published: true
description: An essay on how to have URL encoded tweets when using the Twitter API
tags: Twitter, API
canonical_url: https://webdva.github.io/a-consideration-on-url-encoding-when-posting-a-tweet-on-the-twitter-platform/
---

This essay shows you how to have URL encoded tweets when using the Twitter API.

When Twitter API user agents or clients request for a tweet to be posted on the Twitter platform, the Twitter API documentation specifies that tweets should be "[URL encoded as necessary](https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update)."

If you send an API request to post a tweet without accounting for the URL encoding that the Twitter platform will perform on your proposed tweet, then it's possible that the proposed tweet will become elongated and thus exceed the 280 character limit. That would cause the Twitter API server to send an API error in response, namely specifying that the proposed tweet exceeds the 280 character limit. To resolve this, we'll need an algorithm for solving the problem of maximizing the number of characters we can request the Twitter platform API server to accept, which is the object of this discussion.

We consider the following algorithm:

1. Encode the original tweet message string to be a URI encoded string.
2. Extract the first 280 characters of the new URI encoded string.
3. Using the shortened form of the encoded string, decode it from an encoded URI string into a non-encoded URI string.

To encode the string, we use the `encodeURIComponent` built-in JavaScript function. Then we use the `substr` string method to extract the first 280 characters of the encoded string. Then, to decode the encoded string, the `decodeURIComponent` built-in JavaScript function is used.

An implementation of the algorithm in JavaScript:

``` javascript
const URIEncodedString = encodeURIComponent(original_tweet_message_string);
const shortenedURIEncodedString = URIEncodedString.substr(0, 280);
const decodedShortenedURIEncodedString = decodeURIComponent(shortenedURIEncodedString);
```

The `original_tweet_message_string` variable is the tweet status string that is being requested to be posted.

Note that the URI encoding may fail for whatever reason and that that would require you to handle the error in some way. That can be considered a disadvantage of this algorithm, or at least this JavaScript implementation of the algorithm.

Following the algorithm's execution, we now have a string that can confidently be sent to the Twitter API server. The server will perform its encoding on the string and the resulting proposed tweet status string will not exceed the 280 character restriction due to the preprocessing we performed.
Discuss: Favorite Non-Tech Hobby / Activity
Tags: discuss, hobby, activity, nontech
Published: 2018-10-02 01:21:40

---
title: Discuss: Favorite Non-Tech Hobby / Activity
published: true
description: What's your favorite non-tech hobby that makes you happy?
tags: discuss, hobby, activity, nontech
---

Tech is cool and all, but I want to find out what cool things other people are up to outside of work and technical projects. What makes you *tick* besides computers? Hopefully people respond on this, and if they do, respond if you like the same things!

For myself, there's a few things I enjoy:

* I love hiking and adventuring. I am currently attempting to climb all 46 Adirondack High Peaks. Although I just moved to NYC and work in tech, my heart belongs to the beautiful outdoors. I just started taking pictures, but you can [check some of mine out](https://blog.danstarner.com/photo-galleries/).
* I enjoy racing, [especially on dirt](https://www.youtube.com/watch?v=Xq_n_AUZjOs). I have a [local dirt track](http://www.ransomvillespeedway.com/) that I grew up attending the weekend races at, and I just recently have been pit-crewing a car there weekly. Something about the speed, danger, and precision just seems so appealing to me.
* Music is great. I've played guitar casually for about 10 years now, and would love to find people in the NYC area to jam with 🎸

What hobbies and activities do you like? 😃
where is vue.config.js?
Tags: help
Published: 2018-10-02 01:08:12

---
title: where is vue.config.js?
published: true
tags: help
---

Hi

I new in vue, where is the vue.config.js?

I read the documentation, but I do not understand

https://cli.vuejs.org/config/#vue-config-js


thanks.

Edit:solved...  appears magically
Quick CSS Quiz #2
Tags: challenge, css, quick, quiz
Published: 2018-10-01 21:10:42

---
title: Quick CSS Quiz #2
published: true
description: A quick CSS quiz, can be solved under 5 minutes.
tags: challenge, css, quick, quiz
cover_image: https://thepracticaldev.s3.amazonaws.com/i/d4f2eo4ap4m8b5u7f4ik.jpg
series: quick css quiz
---
In this series, I try to focus on CSS weird parts, throw quiz and its answer, hoping to give a better understanding of how CSS works in depth.


## The problem:
Having the following code snippet, for two divs, the `#container` div has a width of **300px** and hight of **200px**, the `#box` div has **100%** padding-left and padding-top.
what is the rendered `#box` div width and height respectively?


```html
<div id="container" style="width: 300px; height: 200px;">
    <div id="box" style="padding-top: 100%; padding-left: 100%;"></div>
</div>
```

## Options:
* 200px and 200px
* 300px and 300px
* 200px and 300px
* 300px and 200px


## The answer:
you can find the answer below, but please give yourself a couple of minutes to think about it, to make sure you benefit from this quiz.


---
---
---
---
---
<center>👇👇👇</center>
---
---
---
---
---

The correct answer is: **`"300px and 300px"`** 🎉🎉
If you wonder why this is the correct answer, please read the discussions below.
Hacktoberfest 2018: JavaScript OSS that needs contributors
Tags: hacktoberfest, javascript, opensource
Published: 2018-10-01 21:09:59

---
title: Hacktoberfest 2018: JavaScript OSS that needs contributors
published: true
description: 
tags: hacktoberfest, javascript, open source
---

I've not been actively contributing to opensource projects before now but having been following Hacktoberfest for a while before it finally got started today, I've been trying to clear out time on my schedule to contribute to a few open source projects and here I am looking for open source javascript projects I can contribute to.

#### Why JavaScript
I decided to go with JavaScript because I've been working with it at work and I've been actively learning and growing my skills with the language.

Anyone who has a JavaScript-based OSS project that needs contributors can drop links and a little description of the project so I can have options to contribute to.

#HelpMeToHelpYou
Autonomy
Tags: discuss, programming, autonomy
Published: 2018-10-01 20:55:18

---
title: Autonomy 
published: true
tags: discuss, programming, autonomy
---
According to Daniel Pink, autonomy is a central pillar of motivation.

I am fortunate to have a lot of autonomy at work, from booking a hotel I like when I travel, to deciding what I work on most days.

I can confirm that’s motivating.

How important is autonomy to you? Where does/should it start and end?
Muxer, an open source events aggregator looking for contributors
Tags: opensource, hacktoberfest, python, react
Published: 2018-10-01 20:40:39

---
title: Muxer, an open source events aggregator looking for contributors
published: true
description: 
tags: #opensource #hacktoberfest #python #react
---

![Muxer Site](https://thepracticaldev.s3.amazonaws.com/i/0x3zthjsuaca5g2b2jzi.png)

[Muxer](https://muxer.co.uk), an open-source events aggregator build using React and Python. Everyone is welcome to contribute and earn contributions towards #hacktoberfest.

There are a range of labeled [issues](https://github.com/apoclyps) with #hacktoberfest for both React and Flask, however, we also welcome new ideas and contributions of all sizes so let us know if there is something you would like to work on that isn't listed.
WebGL 3D simulation
Tags: help, showdev, webgl
Published: 2018-10-01 19:58:04

---
title: WebGL 3D simulation
published: true
description: 
tags: help, showdev, webgl
cover_image: https://www.soft8soft.com/wp-content/uploads/2018/08/blender_to_webgl.jpg
---

Hello! 

First of all I'd like to say "Hi!" to everybody from my first post and thank you for being such a good community.

### I'd like you to explain my situation

I recently started creating 3D WebGL simulation for my Bachelor's thesis. Sounds fun right? I'll have to simulate autonomic car on highway stuck between truck convoy. 

### Requirements

* WebGL
* 3D models

### My skill set

I'm working as Frontend Angular Dev. I have pretty solid experience in JavaScript (around 2 years). 

I also poked around [PIXI.js](http://www.pixijs.com/) rendering engine a little

### More about work right now :)

I was advised to use Blender. So I created this handsome boi:

![Blender truck](https://thepracticaldev.s3.amazonaws.com/i/h2fx2qk0zud1tj22e7db.PNG)
<figcaption style="color: grey; font-size: 6px">Blender model</figcaption >

I exported collada and used [CubicVR.js](https://github.com/cjcliffe/CubicVR.js/) to render my model in WebGL.

![CubicVR.js](https://thepracticaldev.s3.amazonaws.com/i/5w9uzmer3mqvjgemnrx8.PNG)
<figcaption style="color: grey; font-size: 6px">WebGL rendered model via CubicVR - availible [here](http://webgl.martinfilo.me/)</figcaption >


I will continue on creating some more models and scenery. Later I will join these models with some nice differential equations. Then I will do some magic and avoid collisions!

### Help

I'd like to ask what are my possibilities from you guys, who have experience in this field. 

* Are there any other programs worth trying to create 3D models? 
* Should I keep using CubicVR or are there any better engines?
* What should I read/study/try?

Thank you for any advice!

Regards,
Martin
The 7 Most Popular DEV Posts from the Past Week
Tags: top7, bestofdev
Published: 2018-10-01 18:27:20

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi, bestofdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---

#1. 🔀 Swapping Variables 🔀

Nick really got the community talking with this challenge.  Over 100 comments consisting of clever solutions, discussions of memory, and more.

{% link https://dev.to/theoutlander/how-can-you-swap-two-variables-without-using-a-third-2f30 %}

#2. ✅ New environment setup ✅

Jorge describes his process for getting a development environment up and running.  Don't miss [part 2](https://dev.to/jorge_rockr/my-development-environment-setup-part-2-4ck9).

{% link https://dev.to/jorge_rockr/my-development-environment-setup-part-1-4a33 %}

#3. ⌚Async code ⌚

A dive into asynchronous code, and what makes it such a complicated and confusing concept.  Oftentimes, the issue starts with a misunderstanding of how JavaScript works.

{% link https://dev.to/joelnet/why-async-code-is-so-damn-confusing-and-a-how-to-make-it-easy-3441 %}

#4. 🙏🏽 Your Job is a Job 🙏🏽

"Saying Junior developers should be 'thankful' for getting hired is toxic af."  This thread dives into the all-too-common difference in perception and treatment of "junior" v. "senior" developers.

{% link https://dev.to/lethargilistic/you-deserve-to-be-a-software-developer-14l8 %}

#5. 🎨 Generate Art! 🎨

Ali helps introduce us to the world of generative art, full of CodePen examples and an introduction to p5.js. 

{% link https://dev.to/aspittel/intro-to-generative-art-2hi7 %}

#6. 🙄 My way is the best way 🙄

A conference speaker presented their solution as the "best" while knocking other approaches.  In this article, John explores the underlying behavior of why this attitude is so common. 

{% link https://dev.to/jhotterbeekx/my-solution-is-the-best-1pjk %}

#7. 🔨Tools galore: productivity, media, and more! 🔩

A great round-up of tools that every developer should know about.  Ranging from productivity, operations, QA, to photo editors, to timers and music players.

{% link https://dev.to/bgadrian/16-free-toolsservices-that-any-developer-should-use-4e7e %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_