Posts

Codeigniter Where And Condition Code Example

Example: codeigniter select for update $table = "my_table"; $id = 1; $update = ["status"=>"working"]; //Edit just above /\ if you don't need extra "where" clause $query = $this->db->select() ->from($table) ->where('id', $id) ->get_compiled_select(); $data = $this->db->query("$query FOR UPDATE")->row_array(); $this->db->where('id', $data['id'])->update($table,$update);

Automated Csv Import To Mysql Server Code Example

Example: automated csv import to mysql server #!/bin/bash IMPORTED_FILE_PATH=/path/to/your/imported/file.csv TABLENAME=target_table_name DATABASE=db_name TMP_FILENAME=/tmp/${TABLENAME}.cvs # do nothing if imported file does not exist [ -f "$IMPORTED_FILE_PATH" ] || exit 0 # if temporary file exists, then it means previous import job is running. Also do nothing [ -f "$TMP_FILENAME" ] && exit 0 # Move it to tmp and rename to target table name mv "$IMPORTED_FILE_PATH" "$TMP_FILENAME" mysqlimport --user=mysqlusername --password=mysqlpassword --host=mysqlhost --local $DATABASE $TMP_FILENAME rm -f "$TMP_FILENAME"

Changing The "tick Frequency" On X Or Y Axis In Matplotlib?

Answer : You could explicitly set where you want to tick marks with plt.xticks : plt.xticks(np.arange(min(x), max(x)+1, 1.0)) For example, import numpy as np import matplotlib.pyplot as plt x = [0,5,9,10,15] y = [0,1,2,3,4] plt.plot(x,y) plt.xticks(np.arange(min(x), max(x)+1, 1.0)) plt.show() ( np.arange was used rather than Python's range function just in case min(x) and max(x) are floats instead of ints.) The plt.plot (or ax.plot ) function will automatically set default x and y limits. If you wish to keep those limits, and just change the stepsize of the tick marks, then you could use ax.get_xlim() to discover what limits Matplotlib has already set. start, end = ax.get_xlim() ax.xaxis.set_ticks(np.arange(start, end, stepsize)) The default tick formatter should do a decent job rounding the tick values to a sensible number of significant digits. However, if you wish to have more control over the format, you can define your own formatter. For example...

Android Mirror Vector Drawable

Image
Answer : For those who Use ImageView or TextView or EditText Scale works perfectly. Use android:scaleX="-1" //To flip horizontally or android:scaleY="-1" //To flip vertically OR Try android:rotationX="180" // for horizontal android:rotationY="180" // for vertical OR Simply rotation="180" for vertical android:rotation="180" // for vertical Edit: Additional If you want to flip/mirror icons/drawable when changing language RTL/LTR ("Right To Left"/"Left To Right"), there is a nice way of doing so in android vector drawable just check the ckeckbox Enable auto mirroring for RTL layout . => Right Click on drawable folder => New => Vector Asset => Select drawable => check the Checkbox . I am using AndroidStudio 3.0.1 in Windows 10 . well, there is no need to create another vector image, you can do it with one single vector image just make sure you do the following st...

Can't Clone Private Repo On Github From SourceTree

Image
Answer : It happens because SourceTree didn't get some private access from Github while authenticating. So the solution is very simple Login into your Github account on any browser From top right corner select SETTINGS Now select DEVELOPER SETTINGS From DEVELOPER SETTINGS select PERSONAL ACCESS TOKEN Now from PERSONAL ACCESS TOKEN select GENERATE TOKEN Fill Note as sourcetree and Check All Scopes from checkbox as show in below screenshots After Click on Generate Token Now Open sourceTree Click on sourceTree preference & Click add Account Select options as shown in below screen shot Enter username as your Github account username and password as Generated Token from Github Click on SAVE now you might see all your repository are visible and can clone too Hope it helps I had same problem. My fix way: Remove user from SourceTree settings (optional, i not sure); Add you account in setting and generate new SSH key (it's a main part of fix); ...

ASP.NET Core Testing - Get NullReferenceException When Initializing InMemory SQLite Dbcontext In Fixture

Answer : I encountered this problem while trying to do EF Core scaffolding for an Sqlite database. The problem was that I had installed Microsoft.EntityFrameworkCore.Sqlite.Core rather than Microsoft.EntityFrameworkCore.Sqlite . I uninstalled the former package, and ran this command: Install-Package Microsoft.EntityFrameworkCore.Sqlite -Version 3.1.2 Then everything worked. Yup... My bad. I had installed Microsoft.Data.Sqlite.Core version 3.0.0 when I needed version 2.2.6 and I had not installed Microsoft.Data.Sqlite 2.2.6, which I have since installed. It's working now. Also, FYI: both .UseSqlite("Data Source=:memory:") and .UseSqlite("DataSource=:memory:") work. I had similar issue when trying to open Microsoft.Data.Sqlite.SqliteConnection , it was throwing System.NullReferenceException as well. The class which was initializing the connection was in library project referencing: Microsoft.Data.Sqlite - v3.1.2 Microsoft.Data.Sqlite.Core - v3...

Ag-Grid Header Styles Not Changing With CSS On Component

Answer : Try using ::ng-deep combinator https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep ::ng-deep .ag-theme-balham .ag-header { background-color: #e0e0e0; } If that does not work, put your css in the global stylesheet and check if the styles are overriden correctly Override the header-cell class instead .ag-theme-balham .ag-header-cell{ background-color: #e0e0e0; } and if you have header-group then .ag-theme-balham .ag-header-cell, .ag-theme-balham .ag-header-group-cell{ background-color: #e0e0e0; }

Youtube Mp3 Downloader Free Code Example

Example 1: youtube mp3 converter You can use WebTools , it's an addon that gather the most useful and basic tools such as a synonym dictionary , a dictionary , a translator , a youtube convertor , a speedtest and many others ( there are ten of them ) . You can access them in two clics , without having to open a new tab and without having to search for them ! - Chrome Link : https : //chrome.google.com/webstore/detail/webtools/ejnboneedfadhjddmbckhflmpnlcomge/ Firefox link : https : //addons.mozilla.org/fr/firefox/addon/webtools/ Example 2: youtube download mp3 I use https : //github.com/ytdl-org/youtube-dl/ as a Python CLI tool to download videos

Android Studio Login Template Code Example

Example: android studio login page template EditText username = (EditText)findViewById(R.id.editText1); EditText password = (EditText)findViewById(R.id.editText2); public void login(View view){ if(username.getText().toString().equals("admin") && password.getText().toString().equals("admin")){ //correcct password }else{ //wrong password }

3 Oz To Grams Code Example

Example: oz to g 1 ounce (oz) = 28.3495231 grams (g)

Can I Restore A Single Table From A Full Mysql Mysqldump File?

Answer : You can try to use sed in order to extract only the table you want. Let say the name of your table is mytable and the file mysql.dump is the file containing your huge dump: $ sed -n -e '/CREATE TABLE.*`mytable`/,/Table structure for table/p' mysql.dump > mytable.dump This will copy in the file mytable.dump what is located between CREATE TABLE mytable and the next CREATE TABLE corresponding to the next table. You can then adjust the file mytable.dump which contains the structure of the table mytable , and the data (a list of INSERT ). I used a modified version of uloBasEI's sed command. It includes the preceding DROP command, and reads until mysql is done dumping data to your table (UNLOCK). Worked for me (re)importing wp_users to a bunch of Wordpress sites. sed -n -e '/DROP TABLE.*`mytable`/,/UNLOCK TABLES/p' mydump.sql > tabledump.sql This can be done more easily? This is how I did it: Create a temporary database (e.g. restore): ...

Bootstrap 4 Multiple Fixed-top Navbars

Answer : Yes, it's possible but you have to position the 2nd one accordingly. The height of the Navbar is ~56px. .fixed-top-2 { margin-top: 56px; } body { padding-top: 105px; } <nav class="navbar navbar-toggleable-sm bg-faded navbar-light fixed-top fixed-top-2"> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar1"> <span class="navbar-toggler-icon"></span> </button> <a href="/" class="navbar-brand">One</a> <div class="navbar-collapse collapse" id="navbar1"> <ul class="navbar-nav"> .. </ul> </div> </nav> <nav class="navbar navbar-toggleable-sm bg-inverse navbar-inverse fixed-top"> <button class="navbar-toggler navbar-toggler-right" type="...

Angular Mater Code Example

Example 1: angular material //To take advantage of Angular Material install it in the terminal $ ng add @angular / material //Choose the options that will be presented to you Example 2: Angular material design /* Answer to: "Angular material design" */ /* Angular Material is a UI component library for Angular JS developers. Angular Material components help in constructing attractive, consistent, and functional web pages and web applications while adhering to modern web design principles like browser portability, device independence, and graceful degradation. Main Website: https://material.angular.io/ Get started here: https://material.angular.io/guide/getting-started For examples on usage of this library go to: https://material.angular.io/components/ */

A Call To SSPI Failed, See Inner Exception - The Local Security Authority Cannot Be Contacted

Answer : This means the other side is using another version of TLS and you are using an older version. Set up security attribute to TLS12 before making the connection. This is a widely known problem, as many providers start using TLS12 (e.g. paypal,amazon and so on). ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Here is the solution, set in the registry: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\KeyExchangeAlgorithms\Diffie-Hellman] "ClientMinKeyBitLength"=dword:00000200 as noted here If you are using SslStream, then you need to explicitly set the TLS version in the AuthenticateAsClient call, for example: ssl.AuthenticateAsClient(url, null, SslProtocols.Tls12, false);

Border-width In Em - But Set A Minimum Border-width

Answer : In CSS3, you can try to (ab)use the max css function, if your browser supports it. border-width: max(1px, 0.1em); border-style: solid; border-color: black; Unfortunately this awesome CSS3 feature isn't supported by any browsers yet, but I hope this will change soon! But in CSS2 – no, you can't. However, you can use JavaScript/jQuery to loop through all elements and increase the border size to 1px. But this will eat so much performance your browser is gonna crash if you have too many elements on your page (e.g. a table with more than 50-100 rows). So in other words, no it's not possible. $("[id$='ReportViewerControl']").find('*') .each(function () { if($(this).is('#ParametersRowReportViewerControl *')) return; //console.log("Processing an element"); //var cls = $(this).attr("class"); // Don't add a border to sort-arrow if ($(this).is...

A = Np.zeros(shape(2,3)) Code Example

Example 1: declare numpy zeros matrix python import numpy as np dimensions = ( 3 , 3 ) np . zeros ( dimensions ) # 3x3 zeros matrix Example 2: np.zeros([8,8,3]) >> > np . zeros ( [ 8 , 8 , 3 ] ) array ( [ [ 0 . ] , [ 0 . ] ] )