on-internet

Set Default Drop Down Value in Bootstrap

I am new to JS and would like to set a default value when the page loads. My HTML: <!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"></script> <script src="shared/shiny.js" type="text/javascript"></script> <script src="css/bootstrap-3.3.6-dist/js/bootstrap.min.js"></script> <link rel="stylesheet" href="css/bootstrap-3.3.6-dist/css/bootstrap.min.css"> <script src="js/app.js" type="text/javascript"></script> </head> <body> <div class="dropdown" id="country_select"> <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Country<span class="caret"></span></

Join the discussion →

create new column of values against an existing string in a csv file in python [duplicate]

I have a program to store a persons name and their score, in a csv file in python. for example this is my current code : student_name = input("Name: ") score = input("Score: ") class_name = "student_scores.csv" file = open(class_name , 'a') file.write(str(student_name) + ", " + str(score) + "\n") file.close() The output csv file is, (name = bob) and (score = 1) : bob, 1 When i enter another score (2) for the same person (bob) the csv file looks like this: bob, 1 bob, 2 However how can i change my code, so that the csv file looks like this (with more than 2 columns) : bob, 1, 2

Join the discussion →

Trying to Load Data from Excel into SQL Server. 32-bit Excel and 64-bit SQL Server Throws Error

I've tried a few different ways to load data from Excel into SQL Server, as shown here: Use [TestDatabase] SELECT * INTO dbo.tbl_SST_Personnel FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0 Xml;HDR=YES;Database=C:\Users\rshuell001\Desktop\DATA - INPUT FILES\STT_Personnel.xlsx', 'SELECT * FROM [tbl_SST_Personnel]') GO insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Users\rshuell001\Desktop\DATA - INPUT FILES\STT_Personnel.xlsx;', 'SELECT * FROM [tbl_SST_Personnel]') select * from tbl_SST_Personnel Insert into tbl_SST_Personnel Select * FROM OPENROWSET('Micros

Join the discussion →

Paramiko, Python, Windows : How to connect to a remote computer and from there to a NAS using SSH

I've seen several questions and answers related to this topic but I've been unable to grasp the howto. What I'm able to do : connect to a remote computer using a Python script using Paramiko and return information, for instance, to ping a switch : ssh = pk.SSHClient() ssh.set_missing_host_key_policy(pk.AutoAddPolicy()) ssh.connect('{}'.format(IP), port=xxx, username='xxx',password='xxx') stdin, stdout, stderr = \ ssh.exec_command('ping -n 1 xxx.xxx.x.x\n') print('Ping switch: \n', stdout.readlines()) What I would like to do but don't know how to : connect once to the computer and then using SS

Join the discussion →

getting the cursor of the user input to be on the same line as the printed statement

I have a program which I would like the user to input the answer on the same line as the question which is printed. the code looks like this: question = 1 number1 = 2 number2 = 2 print(question , ") " , "What is" , number1 , "+" , number2 , "? ") user_ans = int(input("")) #The Answer the user inputs to the question asked print (user_ans) But the Output is: 1) What is (number1) + (number2) ? (the cursor goes here) However how do I get the output to be this: 1) What is (number1) + (number2) ? (the cursor goes here)

Join the discussion →

Error in R: no applicable method for 'predict' applied to an object of class "regsubsets"

I was trying to run codes from textbook ISLR. It is about Best Subset Selection: library(ISLR) #contain data Hitters library(leaps) #use regsubsets regfit.full=regsubsets(Salary~.,Hitters) predict(regfit.full) Then R showed error: Error in UseMethod("predict") :no applicable method for 'predict' applied to an object of class "regsubsets" I am using Windows RStudio Version 0.99.893, R-3.2.4revised-win. I really have no idea why the "predict" cannot apply to "regsubsets". other info: > sessionInfo() R version 3.2.4 Revised (2016-03-16 r70336) Platform: x86_64-w64-mingw32/x64 (64-bit) Running und

Join the discussion →

Confirmation when installing with pip globally

Sometimes when working with Python projects one can forget to activate a virtual environment. Is there a way to get an explicit confirmation when installing Python modules with pip to the global scope instead of a virtual environment?

Join the discussion →

Nominating the same table with CodeIgniter's from() and get() methods doesn't fetch values from all expected columns

I need to make a search feature in my CodeIgniter application, but the search results need 2 tables from my database. time, date and user_product_order_id are from the uhd_user_product_order. user_order_id, sender_name, payment_type, and user_order_reference(this the search key) are from uhd_user_order. In the view, I can view data from my table uhd_user_order, but I can't view the time, date values from user_product_order_id. Can you help me how to join the 2 tables so I can see the correct results from the search? This is my controller function search_keyword() { $cari = $this->input->GET('c

Join the discussion →

codeigniter search with join table

this is my controller function search_keyword() { $cari = $this->input->GET('cari'); $data['dapat'] = $this->order_test_m->search($cari); $this->load->view('admin/a',$data); } this is my model function search($cari) { $this->db->from("uhd_user_order AS t1"); $this->db->join("uhd_user_product_order AS t2", "t1.user_order_id = t2.user_order_id"); $this->db->where('user_order_reference',$cari); $query = $this->db->get('uhd_user_order'); return $query->result(); } this is my view <tr> <th>No.</th> <th>Customer Name</th> <th>Product Code</th> <th>Payment Type</th> <th>Delivery Date</th> <th>Total P

Join the discussion →

Draw a triangle in assembly with fasm

I'm trying to draw a triangle in assembly using fasm but I just can't make it. I have the following code to draw a rectangle and I thought that I should just decrease the [comp] value inside the cycle "ciclopinta" but that just doesn't work (or I'm doing it wrong). org 100h mov ah,4fh mov al,02h mov bx,13h int 10h mov [alt],50 mov [comp], 100 mov dx, 100 mov cx,100 ciclopinta: ciclo1: mov ah,0ch mov al,23h mov bh, 0 int 10h dec cx dec byte[comp] jnz ciclo1 mov cx, 100 mov [comp],100 dec dx dec byte [alt] jnz ciclopinta mov ah, 07h int 21h mov ah,4ch int 21h comp rb 1 alt rb 1

Join the discussion →

GuzzleHttp give me 500 error

I try to use GuzzleHttp with Magento to update my product catalog. I use a pool request to get data from database and I try to post them into magento trought API $apiUrl = 'http://xxx.xxxxx.xxx'; $middleware = new Oauth1([ 'consumer_key' => '-------------------------------', 'consumer_secret' => '-------------------------------', 'token' => '-------------------------------', 'token_secret' => '-------------------------------' ]); $stack->push($middleware); $client = new Client(); $clientUpdate = new Client([ 'base_uri' => $apiUrl, 'handler' => $stack, 'auth' => 'oauth' ]); $mapper = new JsonMa

Join the discussion →

How to solve an error "oTable.draw is not a function" in filtering datatables?

I have a search form above the datatables. When I try to search, I have got the data shows in JSON format, not filtering the datatables. The error is Uncaught TypeError: oTable.draw is not a function Here is the javascript: $(document).ready(function(){ var oTable = $('#surat').DataTable({ processing: true, serverSide: true, ajax: { url: '{!! route("surat") !!}', data: function (d) { d.jenis_surat = $('input[name=jenis_surat]').val(); d.nomor_surat = $('input[name=nomor_surat]').val(); d.perihal = $('input[name=perihal]').val(); } }, columns: [ {data: 'no', name: 'no'}, {data: 'jenis_surat', n

Join the discussion →

scanf_s not enough arguments passed for format string(Visual Studio)

The program showing error as title. What's wrong on the scanf_s function? Any idea? int main() { struct Students { char name[10]; int snum; float point; } st[5]; int i; for (i = 0; i < 5; i++) { printf("-- Student Info --\n-"); printf("Enter Your Name: "); scanf_s("%s", st[i].name); printf("\nEnter Your Number: "); scanf_s("%d", &st[i].snum); } return 0; }

Join the discussion →

TypeError: socket.emit is not a function

I'm trying to write basic online game, just to check my current level in web programming. Here is some code I have right now: var io = require('socket.io') (serv, {}); io.sockets.on('connection', function(socket) { console.log('1 '+socket); function fight (player,monster) { console.log('2 '+socket); monsterData = {}; monsterData.name = monster; switch(monster){ case 'rat 1st level': monsterData.hp = 50; monsterData.attack = 1; monsterData.money = Math.floor(Math.random()*3)+1; break; } result = attack(player,monsterData); console.log('3 '+socket); if(result.winner === 'player'){ db.account.fin

Join the discussion →

Import csv Python with Spyder

I am trying to import a csv file into Python but it doesn't seem to work unless I use the Import Data icon. I've never used Python before so apologies is I am doing something obviously wrong. I use R and I am trying to replicate the same tasks I do in R in Python. Here is some sample code: import pandas as pd import os as os Main_Path = "C:/Users/fan0ia/Documents/Python_Files" Area = "Pricing" Project = "Elasticity" Path = os.path.join(R_Files, Business_Area, Project) os.chdir(Path) #Read in the data Seasons = pd.read_csv("seasons.csv") Dep_Sec_Key = pd.read_csv("DepSecKey.csv") These files im

Join the discussion →

Invalid Command 'RewriteEngine' but mod_rewrite is enabled

I am setting up a gitlab site with this conf file But this error arise: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration I have install apache 2.4.20 from source. And forgot that I have installed 2.4.7 with apt-get. Right now apache -v shows 2.4.7 though. I have followed a lot of solutions but they do not work: Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line) Apache2 ProxyPass for Rails App Gitlab I have check the rewrite modules

Join the discussion →

Schrödinger's variable: the __class__ cell magically appears if you're checking for its presence?

There's a surprise here: >>> class B: ... print(locals()) ... def foo(self): ... print(locals()) ... print(__class__ in locals().values()) ... {'__module__': '__main__', '__qualname__': 'B'} >>> B().foo() {'__class__': <class '__main__.B'>, 'self': <__main__.B object at 0x7fffe916b4a8>} True It seems like the mere mention of __class__ is explicitly checked by the parser? Otherwise we should get something like NameError: name '__class__' is not defined Indeed, if you modify to only check the key instead, i.e. check for '__class__' in locals(), then we only have self in scope as expected. How do

Join the discussion →

Getting every possible substring

I would like to generate every possible consecutive substring of a string, including the end of the word/beginning from the word (cyclic) letter combinations. I've found an example in Python, but the only language I know is Perl (and barely, I'm a beginner). I would appreciate it a lot if someone can help me translating the code to Perl or to help me find a solution in Perl. The Python code is the following: aa='ABCD' F=[] B=[] for j in range(1,len(aa)+1,1): for i in range(0,len(aa),1): A=str.split(((aa*j)[i:i+j])) B=B+A C=(B[0:len(aa)*len(aa)-len(aa)+1]) It gives you: C=['A', 'B', 'C', 'D', '

Join the discussion →

How can I remove tralling backslash from $(ProjectDir)?

I have a command line like this in my post-build event: aspnet_regiis -pef connectionStrings "$(ProjectDir)" -prov "DataProtectionConfigurationProvider" But aspnet_regiis is returning a failure because the tralling \ in the directory. Pass full name, path + web.config doesn't work either. How can I solve this?

Join the discussion →

How to Serialize Avro to a byte array using Avro c# library?

I am looking for a way to serialize Avro to a byte array in Avro C# library. There is a link to do for Avro Java library as described in following link from Avro documentation: https://cwiki.apache.org/confluence/display/AVRO/FAQ#FAQ-Serializingtoabytearray Code copied from above link: ByteArrayOutputStream out = new ByteArrayOutputStream(); BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null); DatumWriter<User> writer = new SpecificDatumWriter<User>(User.getClassSchema()); writer.write(user, encoder); encoder.flush(); out.close(); byte[] serializedBytes = out.toByteArray(); B

Join the discussion →

How to send worksheet in email body?

Is there any way I can attach as well as send a worksheet as an email body. The below VBA code sends the worksheet as an attachment. How can I send a worksheet in the body of email? Sub Email() Dim OutApp As Object Dim OutMail As Object Dim wbTemp As Workbook Dim strFilename As String Dim Sendrng As Range ThisWorkbook.Worksheets("Test Worksheet").Copy Set wbTemp = ActiveWorkbook wbTemp.SaveAs ThisWorkbook.Path & "/" & "TestWb", XlFileFormat.xlOpenXMLWorkbook strFilename = wbTemp.FullName Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next Wi

Join the discussion →

Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/staxex/XMLStreamReaderEx

I am getting an exception, but it isn't a code problem, it is a settings/dependencies problem. I have a work and home computer. The project files are synced via OneDrive. Both computers are running Mac OSX 10.11.4, jdk1.8.0_66.jdk and IntelliJ IDEA 2016.1.1 The code works at my work but at home I get the exception: Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/staxex/XMLStreamReaderEx at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.storeElementAndChildren(StreamReaderBufferCreator.java:195) at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.storeDocu

Join the discussion →

How to check if column header is clicked in datagridview using SelectionChanged event

I'm using SelectionChanged event of a DataGridView. I have a code that will display the value of a DataGridView's cell to a TextBox. However, when I click the column header, this also triggers the code (I assume because of the SelectionChanged event) and will display an error. What I want to achieve is to enclose my codes in the datagridview1_SelectionChanged in an if statement. Wherein: if(column header is clicked) //don't do anything` else //do the display of data to textbox` I just want to know the code for checking if you clicked a header or not.

Join the discussion →
Older stories